Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
|
ecd02eea4f | |
|
1654510a0f | |
|
f02c088201 | |
|
a0abcac6e0 | |
|
cd7adff9cf |
|
@ -0,0 +1,3 @@
|
||||||
|
test-data/*
|
||||||
|
master.csv
|
||||||
|
bins.csv
|
10
sorter.rb
10
sorter.rb
|
@ -47,9 +47,14 @@ end
|
||||||
# output - a hash containing all of our output
|
# output - a hash containing all of our output
|
||||||
#This method converts the output hash to JSON and writes it to "output.json"
|
#This method converts the output hash to JSON and writes it to "output.json"
|
||||||
def write_output_json (output, filename)
|
def write_output_json (output, filename)
|
||||||
|
begin
|
||||||
outfile = File.open(filename,'w')
|
outfile = File.open(filename,'w')
|
||||||
outfile.write(output.to_json)
|
outfile.write(output.to_json)
|
||||||
outfile.close
|
outfile.close
|
||||||
|
rescue
|
||||||
|
pp output
|
||||||
|
abort
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_output_csv (output, filename)
|
def write_output_csv (output, filename)
|
||||||
|
@ -147,8 +152,13 @@ def process_file (file_name, binfile, type)
|
||||||
sections = text.lines("Date and time:", chomp: true) #sections is an arrary of each date section from the text
|
sections = text.lines("Date and time:", chomp: true) #sections is an arrary of each date section from the text
|
||||||
sections.delete_at(0) #we can ignore the first chunk of text
|
sections.delete_at(0) #we can ignore the first chunk of text
|
||||||
sections.each do |chunk|
|
sections.each do |chunk|
|
||||||
|
begin
|
||||||
timestamp = chunk.lines.delete_if {|line| line == "\r\n"}[0] #pulling out the timestamp
|
timestamp = chunk.lines.delete_if {|line| line == "\r\n"}[0] #pulling out the timestamp
|
||||||
timestamp.tr!('/','-').tr!(':','').tr!(' ','_') #remove slashes and colons from timestamp, replaces spaces with unserscores
|
timestamp.tr!('/','-').tr!(':','').tr!(' ','_') #remove slashes and colons from timestamp, replaces spaces with unserscores
|
||||||
|
rescue
|
||||||
|
pp timestamp
|
||||||
|
abort
|
||||||
|
end
|
||||||
timestamp.strip!
|
timestamp.strip!
|
||||||
output = Hash.new #Creating the output storage object
|
output = Hash.new #Creating the output storage object
|
||||||
outfile = file_name + '_' + timestamp
|
outfile = file_name + '_' + timestamp
|
||||||
|
|
Loading…
Reference in New Issue