Created
          October 22, 2014 01:11 
        
      - 
      
 - 
        
Save Nagyman/1d3fa8a13cb20e116dbe to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or 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
    
  
  
    
  | 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