File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -469,6 +469,23 @@ Dialects support the following attributes:
469469 When :const: `True `, spaces immediately following the *delimiter * are ignored.
470470 The default is :const: `False `.
471471
472+ .. note ::
473+
474+ When combining ``delimiter=' ' `` (a space) with ``skipinitialspace=True ``,
475+ the writer must quote empty fields.
476+
477+ If an unquoted empty field would be emitted (for example writing ``'' `` or
478+ values that become empty like :data: `None ` under some quoting modes),
479+ :class: `writer ` raises :exc: `csv.Error `. Quoting (the default
480+ :data: `QUOTE_MINIMAL ` is sufficient) avoids this error.
481+
482+ Example::
483+
484+ >>> import csv, io
485+ >>> buf = io.StringIO()
486+ >>> w = csv.writer(buf, delimiter=' ', skipinitialspace=True,
487+ ... quoting=csv.QUOTE_NONE)
488+ >>> w.writerow(['', 'x']) # raises csv.Error
472489
473490.. attribute :: Dialect.strict
474491
You can’t perform that action at this time.
0 commit comments