On Tue, 14 Oct 2008 03:23:37 +0200, Dotan Cohen <dotancohen@gma il.comwrote:
Google no farther; that's what this line does:
for f in glob.glob('*.vc f'):
--
To email me, substitute nowhere->spamcop, invalid->net.
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.
>>
> 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.
for f in glob.glob('*.vc f'):
--
To email me, substitute nowhere->spamcop, invalid->net.