diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst index 1eb3fe0d4903539..64065a75917af83 100644 --- a/Doc/library/csv.rst +++ b/Doc/library/csv.rst @@ -314,6 +314,11 @@ The :mod:`!csv` module defines the following classes: is given, it is interpreted as a string containing possible valid delimiter characters. + If several delimiters fit the sample equally well --- + for example if both ``','`` and ``';'`` split every row consistently --- + the delimiters ``','``, ``'\t'``, ``';'``, ``' '`` and ``':'`` + are preferred, in this order, + no matter how many times each of them occurs. .. method:: has_header(sample) diff --git a/Lib/csv.py b/Lib/csv.py index 6efa889ed84677e..92bb9b55a4d3eba 100644 --- a/Lib/csv.py +++ b/Lib/csv.py @@ -243,6 +243,10 @@ def __init__(self): def sniff(self, sample, delimiters=None): """ Returns a dialect (or None) corresponding to the sample + + If several delimiters fit the sample equally well, the + delimiters listed in the preferred attribute are preferred, in + that order, no matter how many times each of them occurs. """ quotechar, doublequote, delimiter, skipinitialspace = \