On Tue, Apr 7, 2009 at 1:11 PM, Marc Tompkins <marc.tompk...@gmail.com> wrote:
> Anyway, try this -
>
>> import codecs
>>
>> inp = codecs.open('g:\\data\\amm\\text files\\test20090320.txt', 'r',
>> 'utf-16')
>> outp = open('g:\\data\\amm\\text files\\new_text_file.txt', 'w')
>>
>> for outLine in inp:
>>     outp.write(outLine.strip())
>>
>> inp.close()
>> outp.close()
>
> strip() will remove any leading or trailing whitespace - which should
> include any leftover CR or LF characters.

You really should use rstrip(), leading white space is generally
significant in a text file, trailing white space not so much.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to