Last active
December 19, 2015 12:29
-
-
Save hannahwhy/5955346 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
if ARGV.length < 2 | |
puts "Usage: #$0 [DIRECTORY] [GOAL FILE]" | |
exit 1 | |
end | |
values = {} | |
files = [] | |
goalfile = File.expand_path(ARGV[1]) | |
input_set = Dir["#{ARGV[0]}/*"].map { |fn| File.expand_path(fn) } | |
((input_set - [goalfile]).sort + [goalfile]).each do |c| | |
files << ((c == goalfile) ? 'Cases count' : File.basename(c)) | |
File.read(c).split("\n").map { |l| l.split("\t") }.each do |table, cnt| | |
values[table] ||= [] | |
values[table] << cnt | |
end | |
maxlen = values.values.map(&:length).max | |
values.each do |k, v| | |
if v.length != maxlen | |
(maxlen - v.length).times do | |
v << '0' | |
end | |
end | |
end | |
end | |
puts "Table\t" + files.join("\t") + "\tLatest (actual - expected)" | |
values.keys.sort.each do |k| | |
len = values[k].length | |
diff = values[k][len - 2].to_i - values[k].last.to_i | |
puts "#{k}\t#{values[k].join("\t")}\t#{diff}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment