@@ -323,8 +323,8 @@ The :mod:`csv` module defines the following constants:
323
323
.. data :: QUOTE_MINIMAL
324
324
325
325
Instructs :class: `writer ` objects to only quote those fields which contain
326
- special characters such as *delimiter *, *quotechar * or any of the characters in
327
- *lineterminator *.
326
+ special characters such as *delimiter *, *quotechar *, `` '\r' ``, `` '\n' ``
327
+ or any of the characters in *lineterminator *.
328
328
329
329
330
330
.. data :: QUOTE_NONNUMERIC
@@ -342,10 +342,13 @@ The :mod:`csv` module defines the following constants:
342
342
343
343
.. data :: QUOTE_NONE
344
344
345
- Instructs :class: `writer ` objects to never quote fields. When the current
346
- *delimiter * occurs in output data it is preceded by the current *escapechar *
347
- character. If *escapechar * is not set, the writer will raise :exc: `Error ` if
345
+ Instructs :class: `writer ` objects to never quote fields.
346
+ When the current *delimiter *, *quotechar *, *escapechar *, ``'\r' ``, ``'\n' ``
347
+ or any of the characters in *lineterminator * occurs in output data
348
+ it is preceded by the current *escapechar * character.
349
+ If *escapechar * is not set, the writer will raise :exc: `Error ` if
348
350
any characters that require escaping are encountered.
351
+ Set *quotechar * to ``None `` to prevent its escaping.
349
352
350
353
Instructs :class: `reader ` objects to perform no special processing of quote characters.
351
354
@@ -414,9 +417,16 @@ Dialects support the following attributes:
414
417
415
418
.. attribute :: Dialect.escapechar
416
419
417
- A one-character string used by the writer to escape the *delimiter * if *quoting *
418
- is set to :const: `QUOTE_NONE ` and the *quotechar * if *doublequote * is
419
- :const: `False `. On reading, the *escapechar * removes any special meaning from
420
+ A one-character string used by the writer to escape characters that
421
+ require escaping:
422
+
423
+ * the *delimiter *, the *quotechar *, ``'\r' ``, ``'\n' `` and any of the
424
+ characters in *lineterminator * are escaped if *quoting * is set to
425
+ :const: `QUOTE_NONE `;
426
+ * the *quotechar * is escaped if *doublequote * is :const: `False `;
427
+ * the *escapechar * itself.
428
+
429
+ On reading, the *escapechar * removes any special meaning from
420
430
the following character. It defaults to :const: `None `, which disables escaping.
421
431
422
432
.. versionchanged :: 3.11
@@ -436,9 +446,12 @@ Dialects support the following attributes:
436
446
437
447
.. attribute :: Dialect.quotechar
438
448
439
- A one-character string used to quote fields containing special characters, such
440
- as the *delimiter * or *quotechar *, or which contain new-line characters. It
441
- defaults to ``'"' ``.
449
+ A one-character string used to quote fields containing special characters,
450
+ such as the *delimiter * or the *quotechar *, or which contain new-line
451
+ characters (``'\r' ``, ``'\n' `` or any of the characters in *lineterminator *).
452
+ It defaults to ``'"' ``.
453
+ Can be set to ``None `` to prevent escaping ``'"' `` if *quoting * is set
454
+ to :const: `QUOTE_NONE `.
442
455
443
456
.. versionchanged :: 3.11
444
457
An empty *quotechar * is not allowed.
@@ -447,7 +460,8 @@ Dialects support the following attributes:
447
460
448
461
Controls when quotes should be generated by the writer and recognised by the
449
462
reader. It can take on any of the :ref: `QUOTE_\* constants <csv-constants >`
450
- and defaults to :const: `QUOTE_MINIMAL `.
463
+ and defaults to :const: `QUOTE_MINIMAL ` if *quotechar * is not ``None ``,
464
+ and :const: `QUOTE_NONE ` otherwise.
451
465
452
466
453
467
.. attribute :: Dialect.skipinitialspace
0 commit comments