[plug] Working with Mbox files

Nathan Alberti nalberti at gmail.com
Mon Sep 8 10:01:06 WST 2008


On 04/09/2008, at 12:25 PM, Bernd Felsche wrote:

> "Nathan Alberti" <nalberti at gmail.com> wrote:
>
>> I need to create a report for a bunch of mbox files that shows the  
>> number of
>> mail received for the past 7 days and the unread count (for those  
>> messages)
>
>> Getting the read/unread is easy enough but I'm not sure how to go  
>> about
>> working with the date to limit it to the last 7 days worth of  
>> messages..
>
>> Is there an appropriate library or convert it to something like  
>> Unix time
>> and use arithmetic  ?
>
>> I've had a look a some of the email archiving programs but nothing  
>> really
>> looks to do what I want, mbox grep seems promising but I'm not sure  
>> how to
>> go about appropriate regex on the the date field
>
> Mailbox handling...
> <http://docs.python.org/lib/mailbox-objects.html>
>
> rfc822.parsedate() does most of what you require wrt date decoding.
> <http://docs.python.org/lib/module-rfc822.html>
>
> Sample code to do something a little different at
> <http://code.activestate.com/recipes/157437/>
>
> I suspect that Ruby [ a.k.a. Python with braces :-) ] has similar
> facilities.



Thanks for all your suggestions guys... I ended up kind of cheating..  
Bit of a hack but it gets the job done.

Copy the mbox to a temp file, Use archivemail to delete anything older  
than 7 days then count the number of Read/Unread with grep.


Regards,

Nathan.



More information about the plug mailing list