@@ -324,14 +324,19 @@ The :mod:`!csv` module defines the following classes:
324324
325325 If several combinations fit the sample equally well ---
326326 for example if both ``',' `` and ``';' `` split every row consistently ---
327- the delimiters `` ',' ``, `` '\t' ``, `` ';' ``, `` ' ' `` and `` ':' ``
328- are preferred, in this order,
327+ the delimiters listed in the :attr: ` ~Sniffer.preferred ` attribute
328+ are preferred, in that order,
329329 no matter how many times each of them occurs.
330330
331+ The *lineterminator * parameter is deduced separately,
332+ by a majority vote among the line endings of the sample.
333+ A tie is broken in the order ``'\r\n' ``, ``'\n' ``, ``'\r' ``,
334+ so a sample without a complete line gives ``'\r\n' ``.
335+
331336 .. versionchanged :: next
332337 The dialect is now deduced by trial parsing
333338 and the results may differ from those of earlier Python versions.
334- The *escapechar * parameter can now be detected,
339+ The *escapechar * and * lineterminator * parameters can now be detected,
335340 and the requested *delimiters * are not restricted to ASCII.
336341
337342
@@ -354,6 +359,15 @@ The :mod:`!csv` module defines the following classes:
354359 This method is a rough heuristic and may produce both false positives and
355360 negatives.
356361
362+ The :class: `Sniffer ` class has the following attribute:
363+
364+ .. attribute :: preferred
365+
366+ The list of the delimiters preferred for breaking ties,
367+ in the order of preference.
368+ It can be modified.
369+ Its initial value is ``[',', '\t', ';', ' ', ':'] ``.
370+
357371An example for :class: `Sniffer ` use::
358372
359373 with open('example.csv', newline='') as csvfile:
@@ -377,6 +391,8 @@ The :mod:`!csv` module defines the following constants:
377391 Instructs :class: `writer ` objects to only quote those fields which contain
378392 special characters such as *delimiter *, *quotechar *, ``'\r' ``, ``'\n' ``
379393 or any of the characters in *lineterminator *.
394+ If *doublequote * is :const: `False ` and *escapechar * is set,
395+ the *quotechar * is escaped instead of causing the field to be quoted.
380396
381397
382398.. data :: QUOTE_NONNUMERIC
@@ -481,6 +497,10 @@ Dialects support the following attributes:
481497 On reading, the *escapechar * removes any special meaning from
482498 the following character. It defaults to :const: `None `, which disables escaping.
483499
500+ .. versionchanged :: 3.10
501+ Previously the *escapechar * itself was not escaped,
502+ which lost it on reading.
503+
484504 .. versionchanged :: 3.11
485505 An empty *escapechar * is not allowed.
486506
@@ -528,6 +548,13 @@ Dialects support the following attributes:
528548 When ``True ``, raise exception :exc: `Error ` on bad CSV input.
529549 The default is ``False ``.
530550
551+ Dialects support :func: `copy.replace `,
552+ which returns a copy of the dialect
553+ with the specified formatting parameters replaced.
554+
555+ .. versionchanged :: next
556+ Added support for :func: `copy.replace `.
557+
531558.. _reader-objects :
532559
533560Reader Objects
0 commit comments