Skip to content

BUG: Crash using to_csv with QUOTE_NONE #4328

Closed
@adamaaaa

Description

@adamaaaa

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions