Created
August 6, 2015 10:30
-
-
Save h2rd/191509d716fb5643e3ae to your computer and use it in GitHub Desktop.
This file contains hidden or 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' | |
| raise Exception, 'you must provide a json file' unless ARGV[0] | |
| buffer = File.open(ARGV[0]).read | |
| buffer.gsub!("\n", '') | |
| buffer.gsub!("\t", '') | |
| json = JSON.parse!(buffer) | |
| puts json.first.collect {|k,v| k}.to_csv | |
| puts json.collect {|node| node.collect{|k,v| "#{v}"}.to_csv}.join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment