How Can I Disable Quoting In The Python 2.4 CSV Reader?
I am writing a Python utility that needs to parse a large, regularly-updated CSV file I don't control. The utility must run on a server with only Python 2.4 available. The CSV fi
Solution 1:
I don't know if python would like/allow it but could you use a non-printable ascii code such as BEL or BS (backspace) These I would think to be extremely rare.
Solution 2:
I tried a few examples using Python 2.4.3, and it seemed to be smart enough to detect that the fields were unquoted.
I know you've already accepted a (slightly hacky) answer, but have you tried just leaving the reader.dialect.quotechar
value alone? What happens if you do?
Any chance we could get example input?
Solution 3:
+1 for Triptych
Confirmation that csv.reader automatically handles csv files with out quotes:
>>> import StringIO
>>> import csv
>>> data="""
... 1,2,3,4,5
... 1,2,3,4,5
... 1,2,3,4,5
... """
>>> reader=csv.reader(StringIO.StringIO(data))
>>> for i in reader:
... print i
...
[]
['1', '2', '3', '4', '5']
['1', '2', '3', '4', '5']
['1', '2', '3', '4', '5']
Post a Comment for "How Can I Disable Quoting In The Python 2.4 CSV Reader?"