-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
csv writer with blank lineterminator breaks quoting #67044
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
I'm trying to emit a single line of csv without any line terminators, but specifying lineterminator=None results in a "lineterminator must be set" error, and setting lineterminator='' results in lack of quotes around certain fields. with open("foo.csv", "wb") as csvfile:
csvw = csv.writer(csvfile, quoting=csv.QUOTE_MINIMAL, lineterminator='')
csvw.writerow(["col1","col2\ndata", "col3"]) I expected the contents of the file to be: It should be possible to change the lineterminator without changing the quoting behavior. |
If the line terminator is not \n, there is no reason to quote values with \n in them. (Try your code with lineterminator set to 'd' to see what I mean.) |
Also, it is hard to see how to make this clearer: csv.QUOTE_MINIMAL Hmm. Perhaps it would be a bit clearer if it said "... which contain the special characters delimiter, quotechar, ..." |
Note that |
The reader does not support non-quoted and non-escaped |
…honGH-115741) (cherry picked from commit c688c0f) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…honGH-115741) (cherry picked from commit c688c0f) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…() (pythonGH-115741) (cherry picked from commit c688c0f) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
The text was updated successfully, but these errors were encountered: