-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
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
base: main
Are you sure you want to change the base?
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. |
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/