accept file from stdin
parent
85ca5fe2e1
commit
c9b78d4cfc
11
sorter.rb
11
sorter.rb
|
@ -20,6 +20,7 @@
|
||||||
require 'json'
|
require 'json'
|
||||||
require 'pp'
|
require 'pp'
|
||||||
require 'csv'
|
require 'csv'
|
||||||
|
require 'optparse'
|
||||||
|
|
||||||
#bin_counter expects:
|
#bin_counter expects:
|
||||||
# bin - a hash with strings to search for
|
# bin - a hash with strings to search for
|
||||||
|
@ -62,8 +63,18 @@ def strip_text (text, start, fin)
|
||||||
text.lines(start,chomp: true)[1].lines(fin,chomp: true)[0]
|
text.lines(start,chomp: true)[1].lines(fin,chomp: true)[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
options = Hash.new
|
||||||
|
OptionParser.new do |opts|
|
||||||
|
opts.banner = 'sorter.rb --options'
|
||||||
|
opts.on("-f", "--file file", "Name of the file to process") do |file|
|
||||||
|
options[:file] = file
|
||||||
|
end
|
||||||
|
end.parse!
|
||||||
|
|
||||||
|
|
||||||
csv = CSV.read('./bins.csv')
|
csv = CSV.read('./bins.csv')
|
||||||
text = File.read('tester.txt')
|
text = File.read('tester.txt')
|
||||||
|
text = File.read(options[:file])
|
||||||
text = strip_text(text,'PLOVEINTAKE','PLOVECLOSING')
|
text = strip_text(text,'PLOVEINTAKE','PLOVECLOSING')
|
||||||
output = Hash.new #Creating the output storage object
|
output = Hash.new #Creating the output storage object
|
||||||
bins = Hash.new #This hash stores the bins
|
bins = Hash.new #This hash stores the bins
|
||||||
|
|
Loading…
Reference in New Issue