truss_parser 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/truss_parser/parser.rb +4 -5
- data/lib/truss_parser/version.rb +1 -1
- data/normalized_data.csv +9 -9
- data/normalized_test_data.csv +9 -9
- data/scrubbed-sample.csv +9 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4faee8f4044d89d1e63bdac5f7adaff7d3e3256
|
4
|
+
data.tar.gz: 2530411edb5c9b4b75e5118197c8268af7cf250b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32d8baa1f0cebd1fc937f2c27c63f2911b31b552493850e8d92576fa219415a3a2dcc1feabdec9399498797c9a97602eebda4eebb8a3e818f37772aa3bf1d9b9
|
7
|
+
data.tar.gz: bbfeb8a01662cb321adb062cb552e228fae999d3dfa68e6092a5dc349b643868885ba615b3f63be4518b8cdc6e496981aa39c074bbb9dcd752a52a11b9b9f0ca
|
data/Gemfile.lock
CHANGED
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)
|
data/lib/truss_parser/parser.rb
CHANGED
@@ -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'])
|
119
|
-
datetime_est = datetime.in_time_zone(
|
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
|
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
|
|
data/lib/truss_parser/version.rb
CHANGED
data/normalized_data.csv
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
2011-04-
|
2
|
-
2014-03-
|
3
|
-
2016-02-
|
4
|
-
|
5
|
-
|
6
|
-
2011-11-
|
7
|
-
2010-05-
|
8
|
-
2012-10-
|
9
|
-
2004-10-
|
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,
|
data/normalized_test_data.csv
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
2011-04-
|
2
|
-
2014-03-
|
3
|
-
2016-02-
|
4
|
-
|
5
|
-
|
6
|
-
2011-11-
|
7
|
-
2010-05-
|
8
|
-
2012-10-
|
9
|
-
2004-10-
|
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
|
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.
|
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-
|
11
|
+
date: 2019-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|