Skip to content

bug? with delim_whitespace and 'skiprows' in read_csv #8960

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
kikocorreoso opened this issue Dec 2, 2014 · 4 comments
Closed

bug? with delim_whitespace and 'skiprows' in read_csv #8960

kikocorreoso opened this issue Dec 2, 2014 · 4 comments
Labels
IO CSV read_csv, to_csv

Comments

@kikocorreoso
Copy link

Hi all,

I've updated to version 0.15.1 from 0.14.x (Python3.4) and the following code fails in the latest version if the blank line (third line) in data has a tab or whitespace (I think it should be ignored when skiprows is used):

import io

import pandas as pd

data = """Lat=0  Lon=0
Whatever - Not very important

YYYYMMDD HHMM  M(m/s) D(deg)  T(C)  De(k/m3) PRE(hPa)      RiNumber  RH(%)
19840101 0000   21.7    237    9.1    1.23     996.3           0.09   87.4
19840101 0100   22.4    239    9.4    1.23     995.7           0.10   87.2
19840101 0200   22.5    240    9.5    1.23     995.2           0.11   87.5"""

pd.read_csv(io.StringIO(data), delim_whitespace = True, skiprows = 4)

The output with a whitespace or tab in the third line (blank line part of the header) is:

YYYYMMDD HHMM M(m/s) D(deg) T(C) De(k/m3) PRE(hPa) RiNumber RH(%)
0 19840101 0 21.7 237 9.1 1.23 996.3 0.09 87.4
1 19840101 100 22.4 239 9.4 1.23 995.7 0.10 87.2
2 19840101 200 22.5 240 9.5 1.23 995.2 0.11 87.5

And the output without the whitespace and/or a tab is the expected:

19840101 0000 21.7 237 9.1 1.23 996.3 0.09 87.4
0 19840101 100 22.4 239 9.4 1.23 995.7 0.10 87.2
1 19840101 200 22.5 240 9.5 1.23 995.2 0.11 87.5

pd.show_versions() provides the following output:

INSTALLED VERSIONS
------------------
commit: None
python: 3.4.1.final.0
python-bits: 32
OS: Windows
OS-release: 7
machine: x86
processor: x86 Family 6 Model 37 Stepping 5, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.15.1
nose: 1.3.4
Cython: None
numpy: 1.9.1
scipy: 0.14.0
statsmodels: 0.6.0
IPython: 3.0.0-dev
sphinx: 1.2.3
patsy: 0.3.0
dateutil: 2.1
pytz: 2014.9
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.4.0
openpyxl: None
xlrd: 0.9.3
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
rpy2: 2.4.4
sqlalchemy: 0.9.8
pymysql: None
psycopg2: None
@kikocorreoso
Copy link
Author

BTW, if someone points me to the code to review (I suppose it is in io/parsers.py) I can try to send the patch (it it is a bug 🐛 ).

@jreback
Copy link
Contributor

jreback commented Dec 2, 2014

give a try with master
#8752 this issue fixed this

@kikocorreoso
Copy link
Author

Thanks!!!!

And sorry for the noise.

@jreback
Copy link
Contributor

jreback commented Dec 2, 2014

pls report back though (and close if needed)
these bugs can be pretty subtle

@jreback jreback added the IO CSV read_csv, to_csv label Dec 3, 2014
@jreback jreback closed this as completed Dec 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO CSV read_csv, to_csv
Projects
None yet
Development

No branches or pull requests

2 participants