Skip to content

Instantly share code, notes, and snippets.

@zph
Created July 31, 2013 01:59
Show Gist options
  • Save zph/6118725 to your computer and use it in GitHub Desktop.
Save zph/6118725 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
require 'json'
require 'CSV'
require 'open-uri'
json_files = Dir.glob("*.json")
content = json_files.map do |file|
JSON.parse open(file).read
end
options = { headers: ["safe_title", "transcript", "alt"], col_sep: "~" }
CSV.open("output.csv", "w+", options) do |csv|
content.each do |row|
row_values = [row["safe_title"], row["transcript"], row["alt"]]
csv << row_values
end
end
require'pry';binding.pry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment