-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Crash using to_csv with QUOTE_NONE #4328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
seems to work fine in 0.11 (fyi pls post your code
|
I tried to get you a minimal reproduction of the issue. It seems to occur if a string in the DataFrame contains the quote character " but quoting is set to QUOTE_NONE: import pandas Running this in ipython causes a crash for me: "Error: need to escape, but no escapechar set" And by way of validation: In [7]: pandas.version Thanks, Adam |
thanks for the report....and good example...marked as a bug for 0.13 |
@adamaaaa this should work now. |
Hello adamaaaa, I am having some issues in my code and I was hoping you can point me in the right direction. import pandas df = pandas.DataFrame({'A': ['1.0627', '0625', '"LTE,eHRPD"']}) df.to_csv(quoting=csv.QUOTE_NONE) |
Using release 0.11.0 with Python 2.7.1, but it doesn't look like anything has changed in git since.
I can write DataFrames to a file using to_csv fine unless I pass the option: quoting=pandas.io.parsers.csv.QUOTE_NONE in which case I get exceptions of the form:
packages/pandas/core/format.py", line 1054, in _save_chunk
lib.write_csv_rows(self.data, ix, self.nlevels, self.cols, self.writer)
File "lib.pyx", line 832, in pandas.lib.write_csv_rows (pandas/lib.c:13466)
_csv.Error: need to escape, but no escapechar set
A short search reveals links like http://www.velocityreviews.com/forums/t612166-how-can-i-use-quotes-without-escaping-them-using-csv.html implying that due to some csv oddities we should be setting something like quotechar=None when calling csv.writer.
I tried modifying pandas/core/format.py to add quotechar=None to the call to csv.writer and this does indeed seem to fix the problem. Unfortunately I don't have everything set up to build from git so I can't submit a patch.
Thanks.
The text was updated successfully, but these errors were encountered: