Skip to content

Instantly share code, notes, and snippets.

@psteffek
Forked from davidpelayo/mbox-to-csv.py
Last active November 6, 2020 20:41
Show Gist options
  • Save psteffek/2695458ae87a1dacb16104092687bf3b to your computer and use it in GitHub Desktop.
Save psteffek/2695458ae87a1dacb16104092687bf3b to your computer and use it in GitHub Desktop.
Simple mbox parser to csv in Python
import mailbox
import csv
writer = csv.writer(open("mbox-output.csv", "w"))
for message in mailbox.mbox('file.mbox/mbox'):
writer.writerow([message['message-id'], message['subject'], message['from']])
@psteffek
Copy link
Author

psteffek commented Nov 6, 2020

removing the "b" prevents it from opening as binary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment