-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
quotechar and new-line characters are always quoted or escaped. escapechar is always escaped.
What can also be surprising is different behavior for |
It was. In the past, |
@serhiy-storchaka IIUC, |
Doc/library/csv.rst
Outdated
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`, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
- if quoting is set to :const:
QUOTE_NONE
, it escapes delimiter, quotechar, etc. - if doublequote is False, it escapes quotechar.
There was a problem hiding this comment.
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
There was a problem hiding this 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.
When you're done making the requested changes, leave the comment: |
This what this PR does. |
I have made the requested changes; please review again. |
Thanks for making the requested changes! @terryjreedy: please review the changes made to this pull request. |
Thanks @serhiy-storchaka for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…ythonGH-133209) (cherry picked from commit 536a5ff) Co-authored-by: Serhiy Storchaka <[email protected]>
…ythonGH-133209) (cherry picked from commit 536a5ff) Co-authored-by: Serhiy Storchaka <[email protected]>
GH-136113 is a backport of this pull request to the 3.14 branch. |
GH-136114 is a backport of this pull request to the 3.13 branch. |
…H-133209) (#136113) Co-authored-by: Serhiy Storchaka <[email protected]>
…H-133209) (#136114) Co-authored-by: Serhiy Storchaka <[email protected]>
quotechar and new-line characters are always quoted or escaped. escapechar is always escaped.
csv.writer
withQUOTE_NONE
still requires non-emtpyquotechar
andescapechar
#132813📚 Documentation preview 📚: https://cpython-previews--133209.org.readthedocs.build/