Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

csv.writer withQUOTE_NONE still requires non-emtpyquotechar andescapechar #132813

Open
Assignees
serhiy-storchaka
Labels
extension-modulesC modules in the Modules dirstdlibPython modules in the Lib dirtype-featureA feature request or enhancement
@vadimkantorov

Description

@vadimkantorov

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

Labels

extension-modulesC modules in the Modules dirstdlibPython modules in the Lib dirtype-featureA feature request or enhancement

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp