Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Open
Description
Bug report
Bug description:
I'd like to output all quotes verbatim, without any escaping/quoting, but this fails:
importcsvw=csv.writer(open('test.tsv','w'),delimiter='\t',quoting=csv.QUOTE_NONE)w.writerow(('"hello"','"world"'))# _csv.Error: need to escape, but no escapechar set
When I setescapechar=''
orquotechar=''
, it also fails:
importcsvw=csv.writer(open('test.tsv','w'),delimiter='\t',quoting=csv.QUOTE_NONE,escapechar='')w.writerow(('"hello"','"world"'))# TypeError: "escapechar" must be a 1-character stringimportcsvw=csv.writer(open('test.tsv','w'),delimiter='\t',quoting=csv.QUOTE_NONE,quotechar='')w.writerow(('"hello"','"world"'))# TypeError: "quotechar" must be a 1-character string
I would suggest that underQUOTE_NONE
, escaping of quotes should not be performed at all, or at least allow emptyescapechar
/quotechar
The workaround / hack I found:
importcsvw=csv.writer(open('test.tsv','w'),delimiter='\t',quoting=csv.QUOTE_NONE,quotechar='\t')w.writerow(('"hello"','"world"'))
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
In Progress