import mailbox | |
import csv | |
writer = csv.writer(open("mbox-output.csv", "wb")) | |
for message in mailbox.mbox('file.mbox/mbox'): | |
writer.writerow([message['message-id'], message['subject'], message['from']]) |
This comment has been minimized.
This comment has been minimized.
Thanks for posting this! Quick note about using this with Python 3.6.8 (on Ubuntu 18.04). I got an error trying to write to the .csv file:
By using the So the
Thanks again for sharing this snippet! |
This comment has been minimized.
This comment has been minimized.
@GinaZhai this was 4 years ago. I can't remember; but I'd bet it was Python 2.x. Does it make sense? |
This comment has been minimized.
This comment has been minimized.
Hi David, I'm a newbie at running python scripts. Following the steps on this blog https://kamal.io/blog/exporting-email-threads-from-gmail-into-csv-file I've extracted a mbox file (about 120KB), and have tried to run this script in the same directory using Python 3.8.3rc1 IDLE, but the resulting csv file has 0bytes. I would appreciate any pointers, I am not sure what went wrong? |
This comment has been minimized.
hi, I want to know the version of your python, Thanks