Dealing with \r in CSV fields in Python2.4

Tim Chase python.list at tim.thechases.com
Wed Sep 4 11:32:48 EDT 2013


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 not quite sure what """
Note
The reader is hard-coded to recognize either '\r' or '\n' as
end-of-line, and ignores lineterminator. This behavior may change in
the future.
""" means at [1].  Does that mean that efforts to change the
lineterminator don't have any effect? Or that you can't (currently)
specify anything other than "\r" or "\n"?  Though that is a bit
tangent to the actual issue.

-tkc


[1] http://docs.python.org/2/library/csv.html







More information about the Python-list mailing list