Can Python fix vcard files?

skip at pobox.com skip at pobox.com
Tue Oct 14 03:38:07 CEST 2008


    Dotan> One question, though, is that code unicode-safe in the event that
    Dotan> there are unicode characters in there?

Off the top of my head I don't know (and it may well vary by Python
version).  Just leave out the dangerous parts of the loop to check:

    for f in glob.glob('*.vcf'):
        # corrupt data
        uncooked = open(f, 'rb').read()
        # fix it
        cooked = uncooked.replace('\n ', '')
        # and write it to the bit bucket
        open(os.path.devnull, 'wb').write(cooked)

Skip



More information about the Python-list mailing list