truss_parser 0.1.3 → 0.1.4
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/truss_parser/parser.rb +14 -4
- data/lib/truss_parser/version.rb +1 -1
- data/normalized_data.csv +9 -9
- data/sample.csv +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: afbfa746fe2ef4587407b700fa32c0a494c217f0
|
|
4
|
+
data.tar.gz: f1d8033df613dceb1eb792b08457db5f4a37250c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '09abe3f15629f13283bbbabfb4209f18a1396a940d75afb5e3d6f1b0c15057b86d2f495618bb1fb5d08881f003bcf8875f1f558a2adb907719f1759375c22b04'
|
|
7
|
+
data.tar.gz: 2e2718b41a9343f2d529850f463fdf6734723e503d33f486e5d263bf8e5ce75bbf64da3088c047e78632f86db17f053d7f5d371d151e9fd1c230cadf8b176a72
|
data/Gemfile.lock
CHANGED
data/lib/truss_parser/parser.rb
CHANGED
|
@@ -50,7 +50,7 @@ module Parser
|
|
|
50
50
|
update_timezone(row, 'Pacific Time (US & Canada)', 'Eastern Time (US & Canada)')
|
|
51
51
|
|
|
52
52
|
# any zip codes with less than 5 digits, prepend 0's to them until they are 5 digits long
|
|
53
|
-
validate_zipcode(row['zip'])
|
|
53
|
+
validate_zipcode(row['zip'], row)
|
|
54
54
|
# uppercase all names
|
|
55
55
|
upcase_fullname(row['fullname'])
|
|
56
56
|
|
|
@@ -103,7 +103,14 @@ module Parser
|
|
|
103
103
|
fullname.upcase!
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
def validate_zipcode(zipcode)
|
|
106
|
+
def validate_zipcode(zipcode, row)
|
|
107
|
+
if /\D/ =~ zipcode
|
|
108
|
+
STDERR.puts "Warning: You have some characters that are not numbers in
|
|
109
|
+
your zipcode '#{zipcode}' in row: '#{row}'.
|
|
110
|
+
For the time being, 0's will replace the non-number characters. "
|
|
111
|
+
# remove non number characters in zipcode string
|
|
112
|
+
zipcode = zipcode.gsub!(/\D/, '')
|
|
113
|
+
end
|
|
107
114
|
until zipcode.length == 5 do
|
|
108
115
|
zipcode.prepend('0')
|
|
109
116
|
end
|
|
@@ -115,7 +122,8 @@ module Parser
|
|
|
115
122
|
|
|
116
123
|
def update_timezone(row, beginning_tz, result_tz)
|
|
117
124
|
Time.zone = beginning_tz
|
|
118
|
-
|
|
125
|
+
row['timestamp'].nil? ? timestamp = format_timestamp(row[:timestamp]) : timestamp = format_timestamp(row['timestamp'])
|
|
126
|
+
datetime = timestamp
|
|
119
127
|
datetime_est = datetime.in_time_zone('EST')
|
|
120
128
|
formatted_datetime_est = format_datetime(datetime_est)
|
|
121
129
|
row['timestamp'] = formatted_datetime_est
|
|
@@ -143,11 +151,13 @@ module Parser
|
|
|
143
151
|
calculate_duration(row, :barduration)
|
|
144
152
|
format_timestamp(row[:timestamp])
|
|
145
153
|
rescue ArgumentError => e
|
|
146
|
-
STDERR.puts "Warning: Row #{i} will be deleted due to
|
|
154
|
+
STDERR.puts "Warning: Row #{i} will be deleted due to #{e.message}. Did you mistype a timestamp?
|
|
147
155
|
The following row of data will be dropped:
|
|
148
156
|
'#{row}' "
|
|
157
|
+
|
|
149
158
|
end
|
|
150
159
|
table.by_row![i].delete_if { |_| e.present? }
|
|
160
|
+
table.by_row!.delete_if { |row| row.blank? }
|
|
151
161
|
end
|
|
152
162
|
end
|
|
153
163
|
|
data/lib/truss_parser/version.rb
CHANGED
data/normalized_data.csv
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
2011-04-01T14:00:00-
|
|
2
|
-
2014-03-12T03:00:00-
|
|
3
|
-
2016-02-
|
|
4
|
-
2011-01-
|
|
5
|
-
2017-01-
|
|
6
|
-
2011-11-
|
|
7
|
-
2010-05-12T19:48:12-
|
|
8
|
-
2012-10-06T01:31:11-
|
|
9
|
-
2004-10-02T11:44:11-
|
|
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/sample.csv
CHANGED
|
@@ -7,4 +7,4 @@ Timestamp,Address,ZIP,FullName,FooDuration,BarDuration,TotalDuration,Notes
|
|
|
7
7
|
11/11/11 11:11:11 AM,überTown,10001,Prompt Negotiator,1:23:32.123,1:32:33.123,zzsasdfa,"I’m just gonna say, this is AMAZING. WHAT NEGOTIATIONS."
|
|
8
8
|
5/12/10 4:48:12 PM,Høøük¡,1231,Sleeper Service,1:23:32.123,1:32:33.123,zzsasdfa,2/1/22
|
|
9
9
|
10/5/12 10:31:11 PM,"Test Pattern Town, Test Pattern, TP",121,株式会社スタジオジブリ,1:23:32.123,1:32:33.123,zzsasdfa,1:11:11.123
|
|
10
|
-
10/2/04 8:44:11 AM,The Moon,11,HERE WE GO,1:23:32.123,1:32:33.123,zzsasdfa,
|
|
10
|
+
10/2/04 8:44:11 AM,The Moon,11,HERE WE GO,1:23:32.123,1:32:33.123,zzsasdfa,
|