-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
csv.writer
with QUOTE_NONE
still requires non-emtpy quotechar
and escapechar
#132813
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
Comments
csv.witer
with QUOTE_NONE
still requires non-emtpy quotechar
and escapechar
csv.writer
with QUOTE_NONE
still requires non-emtpy quotechar
and escapechar
The docs say:
So, it aligns with the expected behavior, namely:
I'm converting this into a feature request but since 3.14 is almost feature-frozen, it will need to wait 3.15, unless we consider this as a bug, which I don't as it's documented as such. I don't think we need to change the meaning of QUOTE_NONE. However, we should allow a verbatim output, namely something that considers the content of a field as being whatever between two delimiters. If someone needs to use a delimiter inside a field, they must already have quoted it inside the |
Yeah, I expected that QUOTE_NONE means "do nothing about quoting / attempt to escape quotes", but apparently it's not so... |
For that to happen, I think we need a new quoting strategy, something like |
new |
Yes, but the name is very ambiguous as it's too close to If we want to reduce the number of options, we could simply use flags (namely |
Use The documentation is not accurate. It only mentions the current delimiter, but the quoting is also needed for quotechar, escapechar and the line separator. |
On other hand, there may be a bug in the code too. In other places, quotechar is ignored when quoting is QUOTE_NONE, but not here. I'm working on this. |
Yep, I think it would be good to add this to the docs at the very least |
quotechar and new-line characters are always quoted or escaped. escapechar is always escaped.
quotechar and new-line characters are always quoted or escaped. escapechar is always escaped.
I left the code unchanged. There may be a use case for escaping But |
…s of csv.Dialog attributes Make them similar to PyArg_Parse error messages, mention None as a possible value, show a wrong type and the string length.
The part of the problem is that |
…s of csv.Dialect attributes Make them similar to PyArg_Parse error messages, mention None as a possible value, show a wrong type and the string length.
The docs also don't mention that https://docs.python.org/3/library/csv.html#csv.Dialect.quotechar:
|
…sv.Dialog attributes (GH-133241) Make them similar to PyArg_Parse error messages, mention None as a possible value, show a wrong type and the string length.
…s of csv.Dialog attributes (pythonGH-133241) Make them similar to PyArg_Parse error messages, mention None as a possible value, show a wrong type and the string length. (cherry picked from commit df98a47) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
I'd like to output all quotes verbatim, without any escaping/quoting, but this fails:
When I set
escapechar=''
orquotechar=''
, it also fails:I would suggest that under
QUOTE_NONE
, escaping of quotes should not be performed at all, or at least allow emptyescapechar
/quotechar
The workaround / hack I found:
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: