Re: Can Python fix vcard files?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • skip@pobox.com

    Re: Can Python fix vcard files?


    DotanCan Python go through a directory of files and replace each
    Dotaninstance of "newline-space" with nothing?

    Sure. Something like (*completely* untested, so caveat emptor):

    import glob
    import os

    for f in glob.glob('*.vc f'):
    # corrupt data
    uncooked = open(f, 'rb').read()
    # fix it
    cooked = uncooked.replac e('\n ', '')
    # backup original file for safety
    os.rename(f, '%s.orig' % f)
    # and save it
    open(f, 'wb').write(coo ked)

    --
    Skip Montanaro - skip@pobox.com - http://www.webfast.com/~skip/
Working...