2017-09-13 01:05:37 -04:00
|
|
|
$:.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+") }
|
2017-09-13 01:08:56 -04:00
|
|
|
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] != ""
|
2017-09-13 01:10:31 -04:00
|
|
|
end.compact
|
|
|
|
end.flatten
|
2017-09-13 01:05:37 -04:00
|
|
|
File.open("predictions.json", "w+") do |f|
|
2017-09-13 01:08:56 -04:00
|
|
|
f.puts(ret.to_json)
|
2017-09-13 01:05:37 -04:00
|
|
|
end
|
|
|
|
# outputs.values.each { |f| f.close }
|