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

gh-132813: Fix the csv documentation for quoting and escaping#133209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
serhiy-storchaka wants to merge2 commits intopython:main
base:main
Choose a base branch
Loading
fromserhiy-storchaka:docs-csv-quoting

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchakaserhiy-storchaka commentedApr 30, 2025
edited by github-actionsbot
Loading

quotechar and new-line characters are always quoted or escaped. escapechar is always escaped.


📚 Documentation preview 📚:https://cpython-previews--133209.org.readthedocs.build/

quotechar and new-line characters are always quoted or escaped.escapechar is always escaped.
@vadimkantorov
Copy link

What can also be surprising is different behavior forquotechar="" andquotechar=None. I would make them behave the same (currentlyquotechar="" is not permitted), but it's very subjective indeed

@serhiy-storchaka
Copy link
MemberAuthor

It was. In the past,"" and"\0" were interpreted asNone fordelimiter,quotechar andescapechar. But it was confusing, and it was impossible to use the null character as the delimiter or whatever.

@vadimkantorov
Copy link

@serhiy-storchaka IIUC,quote_char=None is accepted forQUOTE_NONE, butquote_char="" is not, because there is a check that if it's astr, it must be a 1-charstr. For me the fact thatquote_char=None is accepted, butquote_char="" is not is strange (not talking here about the null character"\0", just about empty string)

@serhiy-storchakaserhiy-storchaka added the needs backport to 3.14bugs and security fixes labelMay 8, 2025
@serhiy-storchakaserhiy-storchaka requested a review froma teamMay 13, 2025 10:35
A one-character string used by the writer to escape the *delimiter*,
the *quotechar*, ``'\r'``, ``'\n'`` and any of the characters in
*lineterminator* if *quoting* is set to :const:`QUOTE_NONE`,
the *quotechar* if *doublequote* is :const:`False`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I do not understand this part of the sentence in the original, nor the addition below.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

How would you write it?

Different characters are escaped depending on different conditions:

  • ifquoting is set to :const:QUOTE_NONE, it escapesdelimiter,quotechar, etc.
  • ifdoublequote is False, it escapesquotechar.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Perhaps:

A one-character string for escaping. If quoting is set to :const:QUOTE_NONE, it escapes delimiter, quotechar,  ``'\r'``, ``'\n'`` and any of the characters in *lineterminator*. If doublequote is False, it escapes quotechar

serhiy-storchaka reacted with thumbs up emoji
Copy link
Member

@terryjreedyterryjreedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I am assuming that the fact changes are correct. I code not parse one sentence before and less so now. I am guessing that it needs to be split into 2 sentences.

vadimkantorov reacted with thumbs up emoji
@bedevere-app
Copy link

When you're done making the requested changes, leave the comment:I have made the requested changes; please review again.

@vadimkantorov
Copy link

vadimkantorov commentedMay 13, 2025
edited
Loading

It would be nice if the docs mentioned explicitly thatquotechar=None is also allowed. Currently:
image

which says that "empty" is not allowed, whatever that might be meaning (and many people would considerNone to also qualify as "empty")

@serhiy-storchaka
Copy link
MemberAuthor

This what this PR does.

vadimkantorov reacted with heart emoji

@serhiy-storchaka
Copy link
MemberAuthor

I have made the requested changes; please review again.

@bedevere-app
Copy link

Thanks for making the requested changes!

@terryjreedy: please review the changes made to this pull request.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@vadimkantorovvadimkantorovvadimkantorov left review comments

@aterrelaterrelaterrel approved these changes

@terryjreedyterryjreedyAwaiting requested review from terryjreedy

Assignees
No one assigned
Labels
awaiting change reviewdocsDocumentation in the Doc dirneeds backport to 3.13bugs and security fixesneeds backport to 3.14bugs and security fixesskip news
Projects
Status: Todo
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@serhiy-storchaka@vadimkantorov@aterrel@terryjreedy

[8]ページ先頭

©2009-2025 Movatter.jp