truss_parser 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21b5b585a5031ba1ab4e56c898cdef4ffba8b2ea
4
- data.tar.gz: 2601596e24dcdd0ecdea1ae7516438d3234fa817
3
+ metadata.gz: d4faee8f4044d89d1e63bdac5f7adaff7d3e3256
4
+ data.tar.gz: 2530411edb5c9b4b75e5118197c8268af7cf250b
5
5
  SHA512:
6
- metadata.gz: 8eb6dc0edc8f3bd84b1e4e4dbc1cd26a2c7bc3de3666a5ae6872837e76c49b6e9ba9370bb566b59c4452c259df5aa5819316d0cf6ede03c5f286dbcc73530405
7
- data.tar.gz: 986c117aaa103820b36800985c51250919d6d2a15ed0006eb6fe4a00700718dda236031d43373e3e8d063c3d8ce04d2ddb1a975d987d82c568d8afb41c3a4554
6
+ metadata.gz: 32d8baa1f0cebd1fc937f2c27c63f2911b31b552493850e8d92576fa219415a3a2dcc1feabdec9399498797c9a97602eebda4eebb8a3e818f37772aa3bf1d9b9
7
+ data.tar.gz: bbfeb8a01662cb321adb062cb552e228fae999d3dfa68e6092a5dc349b643868885ba615b3f63be4518b8cdc6e496981aa39c074bbb9dcd752a52a11b9b9f0ca
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- truss_parser (0.1.2)
4
+ truss_parser (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -12,7 +12,7 @@ Assuming you have an environment set up for the Ruby ecosystem:
12
12
  ## Usage
13
13
 
14
14
  - After `gem install`ing the `truss` gem:
15
- - Run `truss_parser sample.csv` to parse and normalize the `sample.csv` that is shipped along in this gem. Alternatively, you can also run `truss_parser sample-with-broken-utf8.csv` as well. The TrussParser gem takes in a CSV file as an argument, and outputs normalized CSV data in `normalized_data.csv`. The `scrubbed-sample.csv` file is in an in-between state: the CSV is cleaned of broken Unicode, but has not had any data manipulation or transformations yet. The `normalized_data.csv` file is _both_ free of broken Unicode and had its data manipulated and transformed according to the specifications in `challenge.md`
15
+ - Run `truss_parser sample.csv` to parse and normalize the `sample.csv` that is shipped along in this gem. Alternatively, you can also run `truss_parser sample-with-broken-utf8.csv` as well. The TrussParser gem takes in a CSV file as an argument, and outputs normalized CSV data in `normalized_data.csv`. The `scrubbed-sample.csv` file is in an in-between state: the CSV is cleaned of broken Unicode, has had rows dropped (if there was bad data), but has not had any data manipulation or transformations yet. The `normalized_data.csv` file is _both_ free of broken Unicode and had its data manipulated and transformed according to the specifications in `challenge.md`
16
16
  - Example:
17
17
 
18
18
  ![Example of gem usage](truss_parser.gif)
@@ -110,13 +110,13 @@ module Parser
110
110
  end
111
111
 
112
112
  def format_timestamp(timestamp)
113
- DateTime.strptime(timestamp, '%m/%d/%y %l:%M:%S %p')
113
+ DateTime.strptime("#{timestamp} PST", '%m/%d/%y %l:%M:%S %p %Z')
114
114
  end
115
115
 
116
116
  def update_timezone(row, beginning_tz, result_tz)
117
117
  Time.zone = beginning_tz
118
- datetime = format_timestamp(row['timestamp']).in_time_zone(beginning_tz)
119
- datetime_est = datetime.in_time_zone(result_tz)
118
+ datetime = format_timestamp(row['timestamp'])
119
+ datetime_est = datetime.in_time_zone('EST')
120
120
  formatted_datetime_est = format_datetime(datetime_est)
121
121
  row['timestamp'] = formatted_datetime_est
122
122
  end
@@ -131,9 +131,8 @@ module Parser
131
131
 
132
132
  def calculate_duration(row, key)
133
133
  duration_seconds = row[key].split(':')
134
- .map { |num| num.to_i }
134
+ .map(&:to_f)
135
135
  .reduce(0) { |num1, num2| num1 * 60 + num2 }
136
-
137
136
  row[key] = duration_seconds
138
137
  end
139
138
 
@@ -1,3 +1,3 @@
1
1
  module TrussParser
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/normalized_data.csv CHANGED
@@ -1,9 +1,9 @@
1
- 2011-04-01T07:00:00-04:00,"123 4th St, Anywhere, AA",94121,MONKEY ALBERTO,5012,5553,10565,I am the very model of a modern major general
2
- 2014-03-11T20:00:00-04:00,"Somewhere Else, In Another Time, BB",00001,SUPERMAN ÜBERTAN,401012,5553,406565,This is some Unicode right h�xxx ü ¡! 😀
3
- 2016-02-29T07:11:11-05:00,111 Ste. #123123123,01101,RÉSUMÉ RON,113012,5553,118565,🏳️🏴🏳️🏴
4
- 2010-12-31T19:00:01-05:00,"This Is Not An Address, BusyTown, BT",94121,MARY 1,5012,0,5012,I like Emoji! 🍏🍎😍
5
- 2016-12-31T18:59:59-05:00,"123 Gangnam Style Lives Here, Gangnam Town",31403,ANTICIPATION OF UNICODE FAILURE,5012,5553,10565,I like Math Symbols! ≱≰⨌⊚
6
- 2011-11-11T06:11:11-05:00,überTown,10001,PROMPT NEGOTIATOR,5012,5553,10565,"I’m just gonna say, this is AMAZING. WHAT NEGOTIATIONS."
7
- 2010-05-12T12:48:12-04:00,Høøük¡,01231,SLEEPER SERVICE,5012,5553,10565,2/1/22
8
- 2012-10-05T18:31:11-04:00,"Test Pattern Town, Test Pattern, TP",00121,株式会社スタジオジブリ,5012,5553,10565,1:11:11.123
9
- 2004-10-02T04:44:11-04:00,The Moon,00011,HERE WE GO,5012,5553,10565,
1
+ 2011-04-01T14:00:00-04:00,"123 4th St, Anywhere, AA",94121,MONKEY ALBERTO,5012.123,5553.123,10565.246,I am the very model of a modern major general
2
+ 2014-03-12T03:00:00-04:00,"Somewhere Else, In Another Time, BB",00001,SUPERMAN ÜBERTAN,401012.123,5553.123,406565.24600000004,This is some Unicode right here. ü ¡! 😀
3
+ 2016-02-29T14:11:11-05:00,111 Ste. #123123123,01101,RÉSUMÉ RON,113012.123,5553.123,118565.24600000001,🏳️🏴🏳️🏴
4
+ 2011-01-01T02:00:01-05:00,"This Is Not An Address, BusyTown, BT",94121,MARY 1,5012.123,0.0,5012.123,I like Emoji! 🍏🍎😍
5
+ 2017-01-01T01:59:59-05:00,"123 Gangnam Style Lives Here, Gangnam Town",31403,ANTICIPATION OF UNICODE FAILURE,5012.123,5553.123,10565.246,I like Math Symbols! ≱≰⨌⊚
6
+ 2011-11-11T13:11:11-05:00,überTown,10001,PROMPT NEGOTIATOR,5012.123,5553.123,10565.246,"I’m just gonna say, this is AMAZING. WHAT NEGOTIATIONS."
7
+ 2010-05-12T19:48:12-04:00,Høøük¡,01231,SLEEPER SERVICE,5012.123,5553.123,10565.246,2/1/22
8
+ 2012-10-06T01:31:11-04:00,"Test Pattern Town, Test Pattern, TP",00121,株式会社スタジオジブリ,5012.123,5553.123,10565.246,1:11:11.123
9
+ 2004-10-02T11:44:11-04:00,The Moon,00011,HERE WE GO,5012.123,5553.123,10565.246,
@@ -1,9 +1,9 @@
1
- 2011-04-01T07:00:00-04:00,"123 4th St, Anywhere, AA",94121,MONKEY ALBERTO,5012,5553,10565,I am the very model of a modern major general
2
- 2014-03-11T20:00:00-04:00,"Somewhere Else, In Another Time, BB",00001,SUPERMAN ÜBERTAN,401012,5553,406565,This is some Unicode right h�xxx ü ¡! 😀
3
- 2016-02-29T07:11:11-05:00,111 Ste. #123123123,01101,RÉSUMÉ RON,113012,5553,118565,🏳️🏴🏳️🏴
4
- 2010-12-31T19:00:01-05:00,"This Is Not An Address, BusyTown, BT",94121,MARY 1,5012,0,5012,I like Emoji! 🍏🍎😍
5
- 2016-12-31T18:59:59-05:00,"123 Gangnam Style Lives Here, Gangnam Town",31403,ANTICIPATION OF UNICODE FAILURE,5012,5553,10565,I like Math Symbols! ≱≰⨌⊚
6
- 2011-11-11T06:11:11-05:00,überTown,10001,PROMPT NEGOTIATOR,5012,5553,10565,"I’m just gonna say, this is AMAZING. WHAT NEGOTIATIONS."
7
- 2010-05-12T12:48:12-04:00,Høøük¡,01231,SLEEPER SERVICE,5012,5553,10565,2/1/22
8
- 2012-10-05T18:31:11-04:00,"Test Pattern Town, Test Pattern, TP",00121,株式会社スタジオジブリ,5012,5553,10565,1:11:11.123
9
- 2004-10-02T04:44:11-04:00,The Moon,00011,HERE WE GO,5012,5553,10565,
1
+ 2011-04-01T14:00:00-05:00,"123 4th St, Anywhere, AA",94121,MONKEY ALBERTO,5012.123,5553.123,10565.246,I am the very model of a modern major general
2
+ 2014-03-12T03:00:00-05:00,"Somewhere Else, In Another Time, BB",00001,SUPERMAN ÜBERTAN,401012.123,5553.123,406565.24600000004,This is some Unicode right here. ü ¡! 😀
3
+ 2016-02-29T15:11:11-05:00,111 Ste. #123123123,01101,RÉSUMÉ RON,113012.123,5553.123,118565.24600000001,🏳️🏴🏳️🏴
4
+ 2011-01-01T03:00:01-05:00,"This Is Not An Address, BusyTown, BT",94121,MARY 1,5012.123,0.0,5012.123,I like Emoji! 🍏🍎😍
5
+ 2017-01-01T02:59:59-05:00,"123 Gangnam Style Lives Here, Gangnam Town",31403,ANTICIPATION OF UNICODE FAILURE,5012.123,5553.123,10565.246,I like Math Symbols! ≱≰⨌⊚
6
+ 2011-11-11T14:11:11-05:00,überTown,10001,PROMPT NEGOTIATOR,5012.123,5553.123,10565.246,"I’m just gonna say, this is AMAZING. WHAT NEGOTIATIONS."
7
+ 2010-05-12T19:48:12-05:00,Høøük¡,01231,SLEEPER SERVICE,5012.123,5553.123,10565.246,2/1/22
8
+ 2012-10-06T01:31:11-05:00,"Test Pattern Town, Test Pattern, TP",00121,株式会社スタジオジブリ,5012.123,5553.123,10565.246,1:11:11.123
9
+ 2004-10-02T11:44:11-05:00,The Moon,00011,HERE WE GO,5012.123,5553.123,10565.246,
data/scrubbed-sample.csv CHANGED
@@ -1,10 +1,10 @@
1
1
  timestamp,address,zip,fullname,fooduration,barduration,totalduration,notes
2
- 4/1/11 11:00:00 AM,"123 4th St, Anywhere, AA",94121,Monkey Alberto,5012,5553,zzsasdfa,I am the very model of a modern major general
3
- 3/12/14 12:00:00 AM,"Somewhere Else, In Another Time, BB",1,Superman übertan,401012,5553,zzsasdfa,This is some Unicode right h�xxx ü ¡! 😀
4
- 2/29/16 12:11:11 PM,111 Ste. #123123123,1101,Résumé Ron,113012,5553,zzsasdfa,🏳️🏴🏳️🏴
5
- 1/1/11 12:00:01 AM,"This Is Not An Address, BusyTown, BT",94121,Mary 1,5012,0,zzsasdfa,I like Emoji! 🍏🍎😍
6
- 12/31/16 11:59:59 PM,"123 Gangnam Style Lives Here, Gangnam Town",31403,Anticipation of Unicode Failure,5012,5553,zzsasdfa,I like Math Symbols! ≱≰⨌⊚
7
- 11/11/11 11:11:11 AM,überTown,10001,Prompt Negotiator,5012,5553,zzsasdfa,"I’m just gonna say, this is AMAZING. WHAT NEGOTIATIONS."
8
- 5/12/10 4:48:12 PM,Høøük¡,1231,Sleeper Service,5012,5553,zzsasdfa,2/1/22
9
- 10/5/12 10:31:11 PM,"Test Pattern Town, Test Pattern, TP",121,株式会社スタジオジブリ,5012,5553,zzsasdfa,1:11:11.123
10
- 10/2/04 8:44:11 AM,The Moon,11,HERE WE GO,5012,5553,zzsasdfa,
2
+ 4/1/11 11:00:00 AM,"123 4th St, Anywhere, AA",94121,Monkey Alberto,5012.123,5553.123,zzsasdfa,I am the very model of a modern major general
3
+ 3/12/14 12:00:00 AM,"Somewhere Else, In Another Time, BB",1,Superman übertan,401012.123,5553.123,zzsasdfa,This is some Unicode right here. ü ¡! 😀
4
+ 2/29/16 12:11:11 PM,111 Ste. #123123123,1101,Résumé Ron,113012.123,5553.123,zzsasdfa,🏳️🏴🏳️🏴
5
+ 1/1/11 12:00:01 AM,"This Is Not An Address, BusyTown, BT",94121,Mary 1,5012.123,0.0,zzsasdfa,I like Emoji! 🍏🍎😍
6
+ 12/31/16 11:59:59 PM,"123 Gangnam Style Lives Here, Gangnam Town",31403,Anticipation of Unicode Failure,5012.123,5553.123,zzsasdfa,I like Math Symbols! ≱≰⨌⊚
7
+ 11/11/11 11:11:11 AM,überTown,10001,Prompt Negotiator,5012.123,5553.123,zzsasdfa,"I’m just gonna say, this is AMAZING. WHAT NEGOTIATIONS."
8
+ 5/12/10 4:48:12 PM,Høøük¡,1231,Sleeper Service,5012.123,5553.123,zzsasdfa,2/1/22
9
+ 10/5/12 10:31:11 PM,"Test Pattern Town, Test Pattern, TP",121,株式会社スタジオジブリ,5012.123,5553.123,zzsasdfa,1:11:11.123
10
+ 10/2/04 8:44:11 AM,The Moon,11,HERE WE GO,5012.123,5553.123,zzsasdfa,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: truss_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patricia Arbona
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-12 00:00:00.000000000 Z
11
+ date: 2019-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler