Brad Knowles wrote:

>At 7:40 PM -0500 2006-03-03, Karl Zander wrote:
>
>>  So I have to figure out how to change those date formats.
>>   Anyone know of scripts/tools to manipulate these date
>>  formats?
>
>       See FAQ 3.36.


The method in the FAQ is much more complete than the following, but it
is also more cumbersome if you don't already have formail and procmail
installed.

For a one time Quick and dirty to convert:

   From [EMAIL PROTECTED] Thu, 01 Dec 2005 15:02:08 -0500

to

   From [EMAIL PROTECTED] Thu Dec  1 15:02:08 2005

You can try the following:

python script.py <old_mbox >new_mbox

where script.py is between the dashed lines
----------------------------------------------------------
import sys
import time

for line in sys.stdin.readlines():
    if line.startswith('From '):
        fields = line.split()
        date = ' '.join(fields[2:7])
        try:
            t = time.strptime(date, '%a, %d %b %Y %H:%M:%S')
            newtime = time.asctime(t)
            line = ' '.join(fields[0:2] + [newtime] + ['\n'])
        except ValueError:
            pass

    sys.stdout.writelines([line])
----------------------------------------------------------

(I should add this to the FAQ)

-- 
Mark Sapiro <[EMAIL PROTECTED]>       The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

------------------------------------------------------
Mailman-Users mailing list
Mailman-Users@python.org
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org

Security Policy: 
http://www.python.org/cgi-bin/faqw-mm.py?req=show&amp;file=faq01.027.htp

Reply via email to