pandas to_csv output quoting issue
Note: there is currently a small error in the Pandas to_string documentation. It says:
- quoting : int, Controls whether quotes should be recognized. Values are taken from csv.QUOTE_* values. Acceptable values are 0, 1, 2, and 3 for QUOTE_MINIMAL, QUOTE_ALL, QUOTE_NONE, and QUOTE_NONNUMERIC,
respectively.
But this reverses how csv defines the QUOTE_NONE and QUOTE_NONNUMERIC variables.
In [13]: import csv
In [14]: csv.QUOTE_NONE
Out[14]: 3
You could pass quoting=csv.QUOTE_NONE
, for example:
>>> df.to_csv('foo.txt',index=False,header=False)
>>> !cat foo.txt
123,"this is ""out text"""
>>> import csv
>>> df.to_csv('foo.txt',index=False,header=False, quoting=csv.QUOTE_NONE)
>>> !cat foo.txt
123,this is "out text"
but in my experience it's better to quote more, rather than less.