Reputation: 51
Here's my code:
in_reader = reader(open(csv_in))
for row in in_reader:
...do stuff...
It throws _csv.Error complaining of newline in string when it gets to a line like this:
asdf,"asdf",asdf,"asdf"
asdf",asdf
Note that not all fields are quoted, and the problematic field here is basically a quoted field that contains a quote and a newline.
Upvotes: 0
Views: 1537
Reputation: 526683
That's not a proper CSV file. It's trying to read asdf"
as the first field of the second record, and failing.
If there's a quote within a quoted string, it needs to be escaped (often as two double quote characters: ""
).
Upvotes: 1