[issue30034] csv reader chokes on bad quoting in large files

Peter Otten report at bugs.python.org
Tue Apr 11 03:39:06 EDT 2017


Peter Otten added the comment:

While I don't think that the csv module should second-guess broken input you might consider "fixing" your data on the fly:

def close_quote(line):
    if line.count('"') % 2:
        line = line.rstrip("\n") + '"\n'
    return line

with open("data.csv") as f:
    for row in csv.reader(map(close_quote, f)):
        print(row)

That should give the desired output.

----------
nosy: +peter.otten

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30034>
_______________________________________


More information about the Python-bugs-list mailing list