Created
May 25, 2015 09:26
-
-
Save paulanthonywilson/9f173199f023da7d0c1a to your computer and use it in GitHub Desktop.
trello2csv
This file contains 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' | |
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