-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: Python parser now accepts delim_whitespace=True #12958
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,10 @@ | |
Specifies whether or not whitespace (e.g. ``' '`` or ``'\t'``) will be | ||
used as the sep. Equivalent to setting ``sep='\+s'``. If this option | ||
is set to True, nothing should be passed in for the ``delimiter`` | ||
parameter. This parameter is currently supported for the C parser only. | ||
parameter. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
.. versionadded:: 0.18.1 support for the Python parser. | ||
|
||
header : int or list of ints, default 'infer' | ||
Row number(s) to use as the column names, and the start of the data. | ||
Default behavior is as if set to 0 if no ``names`` passed, otherwise | ||
|
@@ -390,7 +393,20 @@ def _read(filepath_or_buffer, kwds): | |
} | ||
|
||
_c_unsupported = set(['skip_footer']) | ||
_python_unsupported = set(_c_parser_defaults.keys()) | ||
_python_unsupported = set([ | ||
'as_recarray', | ||
'na_filter', | ||
'compact_ints', | ||
'use_unsigned', | ||
'low_memory', | ||
'memory_map', | ||
'buffer_lines', | ||
'error_bad_lines', | ||
'warn_bad_lines', | ||
'dtype', | ||
'decimal', | ||
'float_precision', | ||
]) | ||
|
||
|
||
def _make_parser_function(name, sep=','): | ||
|
@@ -647,8 +663,13 @@ def _get_options_with_defaults(self, engine): | |
value = kwds[argname] | ||
|
||
if engine != 'c' and value != default: | ||
raise ValueError('The %r option is not supported with the' | ||
' %r engine' % (argname, engine)) | ||
if ('python' in engine and | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nvm. we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, that's why I wrote it like that. |
||
argname not in _python_unsupported): | ||
pass | ||
else: | ||
raise ValueError( | ||
'The %r option is not supported with the' | ||
' %r engine' % (argname, engine)) | ||
else: | ||
value = default | ||
options[argname] = value | ||
|
@@ -691,6 +712,9 @@ def _clean_options(self, options, engine): | |
" different from '\s+' are"\ | ||
" interpreted as regex)" | ||
engine = 'python' | ||
elif delim_whitespace: | ||
if 'python' in engine: | ||
result['delimiter'] = '\s+' | ||
|
||
if fallback_reason and engine_specified: | ||
raise ValueError(fallback_reason) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add that this was added in 0.18.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gfyoung if you can update this, and lmlk when you push.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.