-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-113785: csv: fields starting with escapechar are not quoted #122110
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
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
@@ -0,0 +1 @@ | |||
:mod:`csv` now correctly parses numeric fields (when used with :const:`csv.QUOTE_NONNUMERIC`) which start with an escape character. |
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.
or csv.QUOTE_STRINGS.
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.
Added in cf05e97
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.
LGTM.
Thanks @MKuranowski for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
…ythonGH-122110) (cherry picked from commit a3327db) Co-authored-by: Mikołaj Kuranowski <[email protected]>
…ythonGH-122110) (cherry picked from commit a3327db) Co-authored-by: Mikołaj Kuranowski <[email protected]>
GH-122258 is a backport of this pull request to the 3.13 branch. |
GH-122259 is a backport of this pull request to the 3.12 branch. |
Thank you for your contribution @MKuranowski. |
…GH-122110) (GH-122258) (cherry picked from commit a3327db) Co-authored-by: Mikołaj Kuranowski <[email protected]>
…GH-122110) (GH-122259) (cherry picked from commit a3327db) Co-authored-by: Mikołaj Kuranowski <[email protected]>
This PR fixes an inconsistency in the _csv.c module, whereby escapechars at the beginning of the field imply that fields are quoted, but escape characters at any other position do not. This only really affects parsing with QUOTE_NONNUMERIC - fields starting with the escape character are incorrectly left as a string, instead of being parsed.
With this change escapechars do not imply a quoted field; which allows fields like
"\\.5"
with QUOTE_NONNUMERIC to be correctly parsed as0.5
.Closes #113785.