-
-
Notifications
You must be signed in to change notification settings - Fork 33k
Closed
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Description
skipinitialspace=True
and delimiter=' '
raise an exception for an unquoted blank field:
The docs do not mention this behavior:
Simple demonstration:
>>> import csv, io
>>> buf = io.StringIO()
>>> w = csv.writer(buf, delimiter=' ', skipinitialspace=True, quoting=csv.QUOTE_NONE)
>>> w.writerow(['', 'x'])
Traceback (most recent call last):
File "<python-input-3>", line 1, in <module>
w.writerow(['', 'x'])
~~~~~~~~~~^^^^^^^^^^^
_csv.Error: empty field must be quoted if delimiter is a space and skipinitialspace is true
This is since gh-115721. The behavior is intentional and the docs should be updated.
Linked PRs
- gh-138005: Document that CSV
skipinitialspace=True
anddelimiter=' '
require quotation for empty fields #138006 - [3.14] gh-138005: Document that CSV
skipinitialspace=True
anddelimiter=' '
require quotation for empty fields (GH-138006) #138798 - [3.13] gh-138005: Document that CSV
skipinitialspace=True
anddelimiter=' '
require quotation for empty fields (GH-138006) #138799
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Projects
Status
Done
Status
Todo