Converting Mailman/Pipermail text archive to mbox

I wanted to import mailing list archive in my Apple Mail.app which support “Files in mbox format”. Found following python script by Paul which converts text archive to mbox.

#!/usr/bin/env python
"""
to-mbox.py:  Insert line feeds to create mbox format

Usage:   ./to-mbox.py  infile outfile
"""
import sys

if len(sys.argv) != 3:
    print __doc__
    sys.exit()

out = open(sys.argv[2],"w")

start = True
for line in open(sys.argv[1]):
    if line.find("From ") == 0:
        if start:
            start = False
        else:
            out.write("\n")
        line = line.replace(" at ", "@")
    out.write(line)

out.close()



Comments

  1. nexoNo Gravatar June 30th

    Comment Arrow

    thanks for sharing, very helpful for importing archives into an imap server 🙂


Add Yours

  • Author Avatar

    YOU


Comment Arrow




About Author

shiv

This author has not yet written a description. Please give them some time to get acquainted with the site and surely they will write their masterpiece.