Last active
November 17, 2023 18:06
-
-
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.
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
#!/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