Skip to content

Instantly share code, notes, and snippets.

@edsu
Last active November 17, 2023 18:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save edsu/40da6defefc31d3268ebfbaff097f922 to your computer and use it in GitHub Desktop.
Save edsu/40da6defefc31d3268ebfbaff097f922 to your computer and use it in GitHub Desktop.
Convert the outbox.json in a Mastodon account export to a CSV with columns published, to, and content.
#!/usr/bin/env python3
import csv
import json
data = json.load(open("outbox.json"))
out = csv.DictWriter(open("outbox.csv", "w"), ["published", "to", "content"])
out.writeheader()
for post in data["orderedItems"]:
# boosts just have the original post URL as content
if type(post["object"]) == str:
content = post["object"]
else:
content = post["object"]["content"]
out.writerow({
"published": post["published"],
"to": "|".join(post["cc"]),
"content": content
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment