Skip to content

Instantly share code, notes, and snippets.

@orf
Last active October 30, 2020 11:33
Show Gist options
  • Save orf/4b64186799e4594e89a80c3b00df5979 to your computer and use it in GitHub Desktop.
Save orf/4b64186799e4594e89a80c3b00df5979 to your computer and use it in GitHub Desktop.
import mailbox
import pathlib
import email
import tqdm
output_mbox = mailbox.mbox(path="output.mbox")
files = list(pathlib.Path("django-developers/mbox/").iterdir())
for path in tqdm.tqdm(files):
msg = email.message_from_bytes(path.read_bytes())
output_mbox.add(mailbox.Message(msg))
output_mbox.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment