Website/slides/talks/2017-4-Tour-JITDs/results/import.rb
Oliver Kennedy ee650b8dd9 reorg + new talk mats
- Added reveal.js v3.5
- One canonical copy of the JITD and Mimir talks for the tour
- Migrated JITD talk to reveal v3.5
2017-09-23 14:34:02 -04:00

20 lines
566 B
Ruby

$:.push("~/ownCloud/CodeSnippets")
require "csvx.rb"
require "util.rb"
require "json"
input = File.csv("predictions.csv")
headers = input.shift.every(2, 1).map { |h| h.gsub(/[^0-9a-zA-Z]/, "_").gsub(/_+/,"_") }
p headers
# outputs = Hash.new { |hash, key| hash[key] = File.new("output_#{headers[key]}.csv", "w+") }
ret = input.map do |l|
(0..(l.length / 2).floor).map do |i|
{ x: l[i*2], y: l[i*2+1], c: i } if l[i*2] != ""
end.compact
end.flatten
File.open("predictions.json", "w+") do |f|
f.puts(ret.to_json)
end
# outputs.values.each { |f| f.close }