read_table fails with MultiIndex input and delim_whitespace=True · Issue #6893 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@mcwitt

Description

@mcwitt

Related #6889

Example:

In [4]: text = """ A B C D E one two three four a b 10.0032 5 -0.5109 -2.3358 -0.4645 0.05076 0.3640 a q 20 4 0.4473 1.4152 0.2834 1.00661 0.1744 x q 30 3 -0.6662 -0.5243 -0.3580 0.89145 2.5838"""

In [5]: pd.read_table(StringIO(text), delim_whitespace=True)

CParserError Traceback (most recent call last) . . . CParserError: Error tokenizing data. C error: Expected 6 fields in line 3, saw 9

This (partially) works if delim_whitespace=True is replaced with sep='\s+', engine='python' (although columns A-D are lost):

In [6]: pd.read_table(StringIO(text), sep='\s+', engine='python') Out[6]: E one two three four
a b 10.0032 5 0.3640 q 20.0000 4 0.1744 x q 30.0000 3 2.5838

[3 rows x 1 columns]