Skip to content

Instantly share code, notes, and snippets.

@h2rd
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save h2rd/2570b0ee8fb5b5726a1e to your computer and use it in GitHub Desktop.

Select an option

Save h2rd/2570b0ee8fb5b5726a1e to your computer and use it in GitHub Desktop.
require 'json'
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}.join(',')
puts json.collect {|node| "#{node.collect{|k,v| v}.join(',')}\n"}.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment