Can Python fix vcard files?
skip at pobox.com
skip at pobox.com
Mon Oct 13 20:39:00 EDT 2008
Dotan> Can Python go through a directory of files and replace each
Dotan> instance of "newline-space" with nothing?
Sure. Something like (*completely* untested, so caveat emptor):
import glob
import os
for f in glob.glob('*.vcf'):
# corrupt data
uncooked = open(f, 'rb').read()
# fix it
cooked = uncooked.replace('\n ', '')
# backup original file for safety
os.rename(f, '%s.orig' % f)
# and save it
open(f, 'wb').write(cooked)
--
Skip Montanaro - skip at pobox.com - http://www.webfast.com/~skip/
More information about the Python-list
mailing list