Skip to content

Instantly share code, notes, and snippets.

@Nagyman
Created October 22, 2014 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nagyman/1d3fa8a13cb20e116dbe to your computer and use it in GitHub Desktop.
Save Nagyman/1d3fa8a13cb20e116dbe to your computer and use it in GitHub Desktop.
import csv
import json
from collections import defaultdict
with open('trello_export.json', "r") as f:
json_data = f.read()
data = json.loads(json_data)
cards = data['cards']
actions = data['actions']
lists = [l for l in data['lists'] if not l["closed"]]
cards_by_list = defaultdict(list)
for card in cards:
cards_by_list[card["idList"]].append(card)
print "Loaded {} cards into {} lists".format(len(cards), len(cards_by_list))
with open('trello_export.csv', 'wb') as csvfile:
writer = csv.writer(csvfile)
list_ids = cards_by_list.keys()
header_row = [l["name"] for l in lists]
writer.writerow(header_row)
while(True):
row = []
empty = 0
for l in lists:
if cards_by_list[l["id"]]:
row.append(cards_by_list[l["id"]].pop()["name"])
else:
empty += 1
row.append("")
writer.writerow(row)
if empty == len(list_ids):
break
print "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment