Text file with mixed end-of-line terminations

Chris Rebert clp2 at rebertia.com
Wed Aug 31 21:58:36 CEST 2011


On Wed, Aug 31, 2011 at 12:37 PM, Alex van der Spek <zdoor at xs4all.nl> wrote:
> I have a text file that uses both '\r' and '\r\n' end-of-line terminations.
>
> The '\r' terminates the first 25 lines or so, the remainder is termiated
> with '\r\n'
<snip>
> Is there a way to make it read one line at a time, regardless of the line
> termination?

Universal Newline Support
http://www.python.org/dev/peps/pep-0278/

http://docs.python.org/library/functions.html#open
(Modes involving "U")

Cheers,
Chris



More information about the Python-list mailing list