-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
32 lines (27 loc) · 1.01 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'bundler/gem_tasks'
require_relative 'lib/summarize_codes'
namespace :codes do
desc 'Summarize code counts from CSV frequency counts'
task :summarize, [:csv_dir] do |t, args|
puts "Loading CSV from #{args.csv_dir}"
summary = {}
Dir.glob(File.join(args.csv_dir, '**', '*.csv')).each do |f|
csv = CSV.read(f)
SummarizeCodes.validate_csv(csv)
SummarizeCodes.summarize_csv(csv,summary)
end
SummarizeCodes.add_stats(summary)
puts("Writing results to ./tmp")
out_dir = File.join(".", "tmp")
ts = Time.now.strftime("%Y%m%d-%H%M%S")
FileUtils.mkdir_p(out_dir)
File.open(File.join(out_dir, "summary%s.json" % ts), 'w') do |f|
f.write(JSON.pretty_generate(summary))
end
summary.each do |oid, codes|
name = HealthDataStandards::Util::CodeSystemHelper.code_system_for(oid)
stats = codes['summary']
puts "#{name}: #{stats['found']} #{stats['not_found']} #{stats['found_once']} #{stats['found_five_or_less']}"
end
end
end