harerun_parser 0.1.1 → 0.1.2
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/lib/harerun_parser/command.rb +13 -17
- data/lib/harerun_parser/version.rb +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: 4f06a13c1697e76f079975802dd0b94a69106285
|
4
|
+
data.tar.gz: d8fd3780b41dfaf7890628dd9cf42cb387d1198a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f5d1789668d478f1cf8893c687e1595f38dd024b6484653b236ed904f7cbd9cf5a899cb126e9688c5a0bba4d65e3884e812e74664927f8fc6d76e0212e838a1
|
7
|
+
data.tar.gz: fe880c602bc7e51e6065418a786dd555bb3c155f71628f0a0b790a0e00d0a79d12e0370dc44dcb305c1f8b2050d46a10c94a38ed5d39831a011bd50d404a5239
|
@@ -3,16 +3,18 @@ require 'harerun_parser/parser'
|
|
3
3
|
|
4
4
|
module HarerunParser
|
5
5
|
class Command < Thor
|
6
|
-
desc 'normalize
|
7
|
-
option :input, require: true
|
6
|
+
desc 'normalize INPUT_FILE_PATH [OUTPUT_FILE_PATH]', 'normalize download file'
|
8
7
|
option :output, require: true
|
9
|
-
def normalize()
|
10
|
-
input_file = options[:input]
|
11
|
-
output_file = options[:output]
|
12
|
-
|
8
|
+
def normalize(input_file, output_file=nil)
|
13
9
|
File.open(input_file, 'r') do |f|
|
14
10
|
harerun = HarerunParser::Parser.new(f)
|
15
|
-
|
11
|
+
|
12
|
+
if output_file.nil?
|
13
|
+
harerun.normalize do |day, place, header, value|
|
14
|
+
puts "#{day},#{place},#{header},#{value}"
|
15
|
+
end
|
16
|
+
else
|
17
|
+
csv = CSV.open(output_file, 'wb')
|
16
18
|
harerun.normalize do |day, place, header, value|
|
17
19
|
csv << [day, place, header, value]
|
18
20
|
end
|
@@ -20,21 +22,15 @@ module HarerunParser
|
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
def places()
|
26
|
-
input_file = options[:input]
|
27
|
-
|
25
|
+
desc 'places INPUT_FILE_PATH', 'get places in csv file'
|
26
|
+
def places(input_file)
|
28
27
|
File.open(input_file, 'r') do |f|
|
29
28
|
p HarerunParser::Parser.new(f).places
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
def headers()
|
36
|
-
input_file = options[:input]
|
37
|
-
|
32
|
+
desc 'headers INPUT_FILE_PATH', 'get headers in csv file'
|
33
|
+
def headers(input_file )
|
38
34
|
File.open(input_file, 'r') do |f|
|
39
35
|
p HarerunParser::Parser.new(f).headers
|
40
36
|
end
|