onyxfish/csvkit — pull request #205 by dallongo (2013-03-05 23:24:10+00:00)
Title: Fix escaping for quotechar and escapechar

The quote characters were never being escaped because doublequote could never be False. Some changes to csvkit/cli.py were needed because all of the attributes of self.args that we are checking for in the CSVKitUtility class already exist so the 'if' statements should be checking that the attributes are not None type instead of simply checking that they exist. This fixes the problem where 'doublequote=False' is never passed into kwargs.

A bug in the Python built-in csv class does not escape the escapechar when writing out with csv.writer. See http://bugs.python.org/issue12178. I have added a few lines as a work-around in csvkit/unicsv.py for UnicodeCSVWriter.writerow(). In the event that the bug is finally fixed in Python, just remove the 10 lines that I've added.