changed output file

batch
Jeff Yates 2020-07-22 15:17:54 -04:00
parent c9b78d4cfc
commit 96740f161a
1 changed files with 5 additions and 4 deletions

View File

@ -48,8 +48,8 @@ end
#write_output expects:
# output - a hash containing all of our output
#This method converts the output hash to JSON and writes it to output.json
def write_output (output)
outfile = File.open('./output.json','w')
def write_output (output, filename)
outfile = File.open(filename,'w')
outfile.write(output.to_json)
outfile.close
end
@ -73,11 +73,12 @@ end.parse!
csv = CSV.read('./bins.csv')
text = File.read('tester.txt')
text = File.read(options[:file])
text = strip_text(text,'PLOVEINTAKE','PLOVECLOSING')
output = Hash.new #Creating the output storage object
bins = Hash.new #This hash stores the bins
outfile = options[:file] + '-out.json'
outfile.slice!('.txt')
csv.each { |bin| bins[bin[0]] = bin[1..].compact } #turn the csv array into a hash, remove nils
@ -87,5 +88,5 @@ bins.each_key do |bin_number|
output[key][:words] = bin_counter(bins[bin_number], text)
output[key][:total] = count_total(output[key])
end
write_output(output)
write_output(output,outfile)