Skip to content

Instantly share code, notes, and snippets.

@paulanthonywilson
Created May 25, 2015 09:26
Show Gist options
  • Save paulanthonywilson/9f173199f023da7d0c1a to your computer and use it in GitHub Desktop.
Save paulanthonywilson/9f173199f023da7d0c1a to your computer and use it in GitHub Desktop.
trello2csv
require 'json'
require 'csv'
json_data = JSON.load(File.read(ARGV.first))
list_names = json_data["lists"].each_with_object({}) {|b, memo| memo[b["id"]] = b["name"]}
lists = json_data["lists"].each_with_object({}) {|b, memo| memo[b["id"]] = []}
json_data["cards"].each do |card|
list_id = card["idList"]
name = card["name"]
lists[list_id] << name
end
out = CSV.generate do |csv|
csv << list_names.values
i = 0
loop do
first_val = nil
row = []
lists.values.each do |l|
first_val ||= l[i]
row << l[i]
end
break unless first_val
csv << row
i = i+=1
end
end
puts out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment