Skip to content

DOC: Clarify when csv separator is being parsed as regex. Resolves #10208 #12781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 4 additions & 3 deletions doc/source/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ filepath_or_buffer : various
:class:`~python:io.StringIO`).
sep : str, defaults to ``','`` for :func:`read_csv`, ``\t`` for :func:`read_table`
Delimiter to use. If sep is ``None``,
will try to automatically determine this. Regular expressions are accepted,
use of a regular expression will force use of the python parsing engine and
will ignore quotes in the data.
will try to automatically determine this. Separators longer than 1 character
and different from ``'\s+'`` will be interpreted as regular expressions, will
force use of the python parsing engine and will ignore quotes in the data.
Regex example: ``'\\r\\t'``.
delimiter : str, default ``None``
Alternative argument name for sep.

Expand Down
9 changes: 6 additions & 3 deletions pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,9 @@ class ParserWarning(Warning):

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

_read_csv_doc = """
Read CSV (comma-separated) file into DataFrame
Expand Down Expand Up @@ -674,7 +675,9 @@ def _clean_options(self, options, engine):
elif engine not in ('python', 'python-fwf'):
# wait until regex engine integrated
fallback_reason = "the 'c' engine does not support"\
" regex separators"
" regex separators (separators > 1 char and"\
" different from '\s+' are"\
" interpreted as regex)"
engine = 'python'

if fallback_reason and engine_specified:
Expand Down