Skip to content

read_csv: delim_whitespace ignored when skip_footer is set #4880

Closed
@rutj3

Description

@rutj3

The delim_whitespace options no longer works when specifying a skip_footer other then zero. I can replicate the behavior in 0.12 with the following example:

import pandas as pd
from StringIO import StringIO

indata = StringIO("""1.2   5.6   8.5
4.5   6.7   6.4


""")

indata.seek(0)
df = pd.read_csv(indata, delim_whitespace=True, header=None, skip_footer=2)

Which returns:

                 0
0  1.2   5.6   8.5
1  4.5   6.7   6.4

Note how its only one column, instead of three. Changing the skip_footer to 0 makes it work as expected.

indata.seek(0)
df = pd.read_csv(indata, delim_whitespace=True, header=None, skip_footer=0)

Returns:

     0    1    2
0  1.2  5.6  8.5
1  4.5  6.7  6.4
2  NaN  NaN  NaN
3  NaN  NaN  NaN

If the above example is used with something like names=['a','b','c'] an (obvious) 'ValueError' exception occurs: Expected 3 fields in line 1, saw 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions