Coder Social home page Coder Social logo

csv_normalization's Introduction

CSV Normalization

This is a tool that reads CSV formatted files from stdin and outputs a parsed version via stdout (unless an output csv file is specified). This parser enforces UTF-8 character encoding and specifically normalizes the following:

  • Timestamp:
    • converted to mISO860 format
    • converted from pacific to eastern timezone
    • if there is null timezone, assumes pacific
  • Address:
    • left as is, except for the general UTF-8 char enforcement
  • Zip:
    • 5 digit validation
      • if 5 digits, left as is
      • if less than 5 digits, 0 is used as prefix
      • if greater than 5 digits (e.g. 12345-1234), digits past - are removed
  • Full Name:
    • converted to UPPERCASE
    • accounts for non-ASCII characters
  • FooDuration & BarDuration:
    • converted to floating points seconds format (with 3 decimal places)
  • Total Duration:
    • sum of FooDuration and BarDuration
  • Notes
    • left as is, except for the general UTF-8 char enforcement

To setup:

This normalizer will work best using Ruby version 2.3.0 or higher.

  • clone repo
  • run bundle install

To normalize CSVs:

From the root directory, run ruby run_normalizer.rb. By default a sample.csv file will be parsed and outputted via stdout. You can specify a file to parse by running ruby run_normalizer.rb {path-to-csv} and likewise, you can specify an output file by running ruby run_normalizer.rb {path-to-csv} output.csv. Example output: test output

Testing:

Testing tool: RSpec To run tests run rspec from root directory. Example test output: test output

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.