Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Doc/library/csv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ The :mod:`!csv` module defines the following classes:
in particular if it is a single column,
so there is no delimiter to find.

If several combinations 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.

.. versionchanged:: next
The dialect is now deduced by trial parsing
and the results may differ from those of earlier Python versions.
Expand Down
4 changes: 4 additions & 0 deletions Lib/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ def sniff(self, sample, delimiters=None):
beginning, then, after eliminating the combinations which are
clearly worse than the leader, a several times larger part,
and so on.

If several combinations 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.
"""
import re
from collections import defaultdict
Expand Down
Loading