I'm looking for a way to define custom quoting
with csv.writer
in Python. There are 4 built-in ways to qoute values:
csv.QUOTE_ALL, csv.QUOTE_MINIMAL, csv.QUOTE_NONNUMERIC, csv.QUOTE_NONE
However I need a quoting mechanism which will emulate Postgres' FORCE QUOTE *
, i.e. it will quote all non-None values. With csv.QUOTE_ALL
Python will turn None into ''
but I would like to have empty string instead.
Is it possible to do that with built-in csv
module ( I'm not interested in hacks, I'm already doing that :P )? Or am I forced to write/get some custom csv parser?
And generally: is it possible to write custom quoting mechanism for csv
module?