Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Convert a Trello JSON export file to an Org file
#!/usr/bin/env python
# trello2org.py
#
# Convert a Trello JSON export file to an Org file.
#
# Export your Trello JSON and run this script on it. Useful for if you're
# migrating your data away to Trello and into Org. It's not particularly fancy,
# nor does it use all of Org's features. But it gets the job done.
#
# Copyright 2014, Noah Slater <nslater@apache.org>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and this
# notice are preserved. This file is offered as-is, without any warranty.
import json
import sys
def convertToOrg(data):
yield "#+TITLE %s\n" % data["name"]
listNames = {}
for trelloList in data["lists"]:
listNames[trelloList["id"]] = trelloList["name"]
lists = {}
for listName in listNames.values():
lists[listName] = []
for card in data["cards"]:
listName = listNames[card["idList"]]
lists[listName].append(card)
checklists = {}
for trelloChecklist in data["checklists"]:
checklists[trelloChecklist["id"]] = trelloChecklist
comments = {}
for action in data["actions"]:
if action["type"] == "commentCard":
cardID = action["data"]["card"]["id"]
if cardID not in comments:
comments[cardID] = []
try:
name = action["memberCreator"]["fullName"]
except:
name = "[deleted account]"
comments[cardID].append(name + ": " + action["data"]["text"])
for listName in lists:
yield "* " + listName
for card in lists[listName]:
name = card["name"]
if card["closed"]:
name = "DONE %s" % name
else:
name = "TODO %s" % name
if card["labels"]:
labels = []
for label in card["labels"]:
if label["name"]:
labels.append(label["name"])
else:
labels.append(label["color"])
name += " (" + ", ".join(labels) + ")"
yield "** " + name
desc = "\n" + card["desc"]
desc = desc.replace("\n*", "\n *")
yield desc[1:]
if card["attachments"]:
yield "Attachments:"
yield ""
for attachment in card["attachments"]:
attachment["url"]
yield ""
if card["idChecklists"]:
for checklistID in card["idChecklists"]:
yield "Checklist:"
yield ""
checklist = checklists[checklistID]
for checkItem in checklist["checkItems"]:
if checkItem["state"] == "complete":
state = "[X]"
else:
state = "[ ]"
yield state + " " + checkItem["name"]
yield ""
if card["id"] in comments:
yield "Comments:"
yield ""
for comment in comments[card["id"]]:
yield comment.replace("\n*", "\n *")
yield ""
def main():
try: name = sys.argv[1]
except:
print("Usage: %s FILENAME" % sys.argv[0])
sys.exit(2)
with open(name) as f:
text = f.read()
data = json.loads(text)
for line in convertToOrg(data):
line = line.replace("\r", "\n")
print(line.encode("utf-8"))
if __name__ == "__main__":
main()
@TheunisKotze

handy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.