On Oct 14, 2008, at 3:23 AM, Dotan Cohen wrote:
2008/10/14 <skip@pobox.com >:
>
Thanks, that's easier than I thought! I am sure with some googling I
will discover how to loop through all the files in a directory. One
question, though, is that code unicode-safe in the event that there
are unicode characters in there?
>
>>
> 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)
>>
> 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)
>>
Thanks, that's easier than I thought! I am sure with some googling I
will discover how to loop through all the files in a directory. One
question, though, is that code unicode-safe in the event that there
are unicode characters in there?
>
value.
Thus, they won't be replaced.
--
Dotan Cohen
>
×-ב-×’-ד-×”-ו-×–-×—-ט-×™-ך-×›-ל-×-מ-ן-× -ס-×¢-×£-פ-×¥-צ-
ק-ר-ש-ת
>
ä-ö-ü-ß-Ä-Ö-Ü
--
http://mail.python.org/mailman/listinfo/python-list
Dotan Cohen
>
×-ב-×’-ד-×”-ו-×–-×—-ט-×™-ך-×›-ל-×-מ-ן-× -ס-×¢-×£-פ-×¥-צ-
ק-ר-ש-ת
>
ä-ö-ü-ß-Ä-Ö-Ü
--
http://mail.python.org/mailman/listinfo/python-list
Skinheads are so tired of immigration, that they are going to move to
a country that don't accept immigrants!
Tommy Nordgren
tommy.nordgren@ comhem.se