Re: Dealing with \r in CSV fields in Python2.4

2013-09-04 Thread Terry Reedy
On 9/4/2013 11:04 AM, Tim Chase wrote: I've got some old 2.4 code (requires an external lib that hasn't been upgraded) that needs to process a CSV file where some of the values contain \r characters. It appears that in more recent versions (just tested in 2.7; docs suggest this was changed in 2.

Re: Dealing with \r in CSV fields in Python2.4

2013-09-04 Thread Tim Chase
On 2013-09-04 16:31, MRAB wrote: > You could try replacing the '\r' with another character that doesn't > appear elsewhere and then change it back afterwards. > > MARKER = '\x01' > > def cr_to_marker(f): > for line in f: > yield line.replace('\r', MARKER) > > def marker_to_cr(item)

Re: Dealing with \r in CSV fields in Python2.4

2013-09-04 Thread Tim Chase
On 2013-09-04 10:20, Skip Montanaro wrote: > > _csv.Error: newline inside string > > How are the lines actually terminated, with \r\n or with just \n? If > it's just \n, what happens if you specify \n as the line terminator? Unfortunately, the customer feed contains DOS newlines ("\r\n"). I'm

Re: Dealing with \r in CSV fields in Python2.4

2013-09-04 Thread MRAB
On 04/09/2013 16:04, Tim Chase wrote: I've got some old 2.4 code (requires an external lib that hasn't been upgraded) that needs to process a CSV file where some of the values contain \r characters. It appears that in more recent versions (just tested in 2.7; docs suggest this was changed in 2.5

Re: Dealing with \r in CSV fields in Python2.4

2013-09-04 Thread Skip Montanaro
> _csv.Error: newline inside string How are the lines actually terminated, with \r\n or with just \n? If it's just \n, what happens if you specify \n as the line terminator? Skip -- https://mail.python.org/mailman/listinfo/python-list

Dealing with \r in CSV fields in Python2.4

2013-09-04 Thread Tim Chase
I've got some old 2.4 code (requires an external lib that hasn't been upgraded) that needs to process a CSV file where some of the values contain \r characters. It appears that in more recent versions (just tested in 2.7; docs suggest this was changed in 2.5), Python does the Right Thing™ and just