You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It may not be clear from the docs, but the input to a unicodecsv reader is expected to be bytes (str in python2), not unicode, so you should be using BytesIO rather than StringIO.
Testing with BytesIO rather than StringIO, I do see the "new-line character seen in unquoted field" error. I think this is a bug in the underlying csv module - https://docs.python.org/2/library/csv.html#csv.Dialect.lineterminator "The reader is hard-coded to recognise either '\r' or '\n' as end-of-line, and ignores lineterminator. This behavior may change in the future."
Using \r (as with your original data), I can reproduce this with a normal file, not io.BytesIO or io.StringIO -- and of course unicodecsv does generally work with files.
When I change your data to use \n rather than \r, then the code works:
As described in this SO question, I am getting the following error with unicodecsv.DictReader:
Here's a simplified version of my code:
If I replace StringIO with BytesIO, the encoding works but I can't send the
newlines
argument anymore and then I get:The text was updated successfully, but these errors were encountered: