Created
December 2, 2014 10:53
-
-
Save tmtmtmtm/e2fe7e52a35ac57e3d8f to your computer and use it in GitHub Desktop.
Convert a Stance file into simple CSV
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
require 'json' | |
require 'csv' | |
file = ARGV.first or raise "Need a filename" | |
json = JSON.parse(File.read(file)) | |
puts json.map { |i| i['stances'].map { |bloc, s| [ i['id'], bloc, s['score'] ].to_csv } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment