Skip to content

Commit 8776596

Browse files
dukebodyjreback
authored andcommitted
DOC: Clarify when csv separator is being parsed as regex. Resolves #10208
closes #10208 Author: Israel Saeta Pérez <[email protected]> Closes #12781 from dukebody/master and squashes the following commits: c7858f6 [Israel Saeta Pérez] DOC: Clarify when csv separator is being parsed as regex. Resolves #10208.
1 parent 64977f1 commit 8776596

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

doc/source/io.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ filepath_or_buffer : various
9191
:class:`~python:io.StringIO`).
9292
sep : str, defaults to ``','`` for :func:`read_csv`, ``\t`` for :func:`read_table`
9393
Delimiter to use. If sep is ``None``,
94-
will try to automatically determine this. Regular expressions are accepted,
95-
use of a regular expression will force use of the python parsing engine and
96-
will ignore quotes in the data.
94+
will try to automatically determine this. Separators longer than 1 character
95+
and different from ``'\s+'`` will be interpreted as regular expressions, will
96+
force use of the python parsing engine and will ignore quotes in the data.
97+
Regex example: ``'\\r\\t'``.
9798
delimiter : str, default ``None``
9899
Alternative argument name for sep.
99100

pandas/io/parsers.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,9 @@ class ParserWarning(Warning):
221221

222222
_sep_doc = """sep : str, default {default}
223223
Delimiter to use. If sep is None, will try to automatically determine
224-
this. Regular expressions are accepted and will force use of the python
225-
parsing engine and will ignore quotes in the data."""
224+
this. Separators longer than 1 character and different from '\s+' will be
225+
interpreted as regular expressions, will force use of the python parsing
226+
engine and will ignore quotes in the data. Regex example: '\\r\\t'"""
226227

227228
_read_csv_doc = """
228229
Read CSV (comma-separated) file into DataFrame
@@ -674,7 +675,9 @@ def _clean_options(self, options, engine):
674675
elif engine not in ('python', 'python-fwf'):
675676
# wait until regex engine integrated
676677
fallback_reason = "the 'c' engine does not support"\
677-
" regex separators"
678+
" regex separators (separators > 1 char and"\
679+
" different from '\s+' are"\
680+
" interpreted as regex)"
678681
engine = 'python'
679682

680683
if fallback_reason and engine_specified:

0 commit comments

Comments
 (0)