Message280384
I could research a bit more on the problem. This is a minimal code that reproduces what happened:
from io import StringIO
import csv
csv_file = StringIO('''1\t"A
2\tB''')
reader = csv.reader(csv_file, delimiter='\t')
for i, row in enumerate(reader):
pass
print(reader.line_num) # 2
print(i + 1) # 1
The reason to return the right number of rows with the default delimiter, is because the quote needs to be immediately after the delimiter to be considered the opening of a quoted text.
If the file contains an opening quote, and the EOF is reached without its closing quote, the reader considers all the text until EOF to be that field.
This would work as expected in a line like:
1,"well quoted text","this one has a missing quote
But it'd fail silently with unexpected results in all other cases. I'd expect csv to raise an exception, more than the current behavior.
Do you agree? Should I create another issue to address this? |
|
Date |
User |
Action |
Args |
2016-11-09 09:11:41 | datapythonista | set | recipients:
+ datapythonista, mrabarnett, SilentGhost, serhiy.storchaka |
2016-11-09 09:11:41 | datapythonista | set | messageid: <1478682701.16.0.0888531163473.issue28642@psf.upfronthosting.co.za> |
2016-11-09 09:11:41 | datapythonista | link | issue28642 messages |
2016-11-09 09:11:40 | datapythonista | create | |
|