Skip to content

Instantly share code, notes, and snippets.

@tmtmtmtm
Created December 2, 2014 10:53
Show Gist options
  • Save tmtmtmtm/e2fe7e52a35ac57e3d8f to your computer and use it in GitHub Desktop.
Save tmtmtmtm/e2fe7e52a35ac57e3d8f to your computer and use it in GitHub Desktop.
Convert a Stance file into simple CSV
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