Skip to content

Instantly share code, notes, and snippets.

@greencm
Created June 28, 2013 20:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save greencm/5887815 to your computer and use it in GitHub Desktop.
Save greencm/5887815 to your computer and use it in GitHub Desktop.
Count the number of messages in an mbox file
#!/usr/bin/env python
# $Id$
# Author: <cmgreen@uab.edu>
# Purpose: Count the number of mails in an mbox file
# Created: Fri Jun 28 10:39:13 CDT 2013
import sys
from mailbox import mbox
import re
def count_mbox(box):
i = 0
for n, msg in box.iteritems():
i+=1
return i
if __name__=='__main__':
for f in sys.argv[1:]:
print f, count_mbox(mbox(f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment