Skip to content
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

read_excel crash with empty Exception #12292

Closed
bteplygin opened this issue Feb 11, 2016 · 3 comments
Closed

read_excel crash with empty Exception #12292

bteplygin opened this issue Feb 11, 2016 · 3 comments
Labels
Milestone

Comments

@bteplygin
Copy link

@bteplygin bteplygin commented Feb 11, 2016

If read one empty column from excel file, read_excel raise Exception without error message.
Small test case: content of excel file:

A B C D
1 100 f
2 200 f
3 300 f
4 400 f

Run:

import pandas as pd
pd.read_excel("test_excel_.xls", parse_cols=[0], header=None)

Result:

File "/home/.../python2.7/site-packages/pandas/io/excel.py", line 170, in read_excelskip_footer=skip_footer, converters=converters, **kwds)
File "/home/.../python2.7/site-packages/pandas/io/excel.py", line 436, in _parse_excel**kwds)
File "/home/.../python2.7/site-packages/pandas/io/parsers.py", line 1346, in TextParserreturn TextFileReader(*args, **kwds)
File "/home/.../python2.7/site-packages/pandas/io/parsers.py", line 590, in __init__self._make_engine(self.engine)
File "/home/.../python2.7/site-packages/pandas/io/parsers.py", line 737, in _make_engineself._engine = klass(self.f, **self.options)
File "/home/.../python2.7/site-packages/pandas/io/parsers.py", line 1452, in __init__self.columns, self.num_original_columns = self._infer_columns()
File "/home/.../python2.7/site-packages/pandas/io/parsers.py", line 1735, in _infer_columnsline = self._buffered_line()
File "/home/.../python2.7/site-packages/pandas/io/parsers.py", line 1793, in _buffered_linereturn self._next_line()
File "/home/.../python2.7/site-packages/pandas/io/parsers.py", line 1817, in _next_lineraise StopIteration

Python 2.7.7
pandas 0.17.1
xlrd 0.9.4

@jreback

This comment has been minimized.

Copy link
Contributor

@jreback jreback commented Feb 11, 2016

can you programatically create this example as a frame and write it to excel, alternatively post a link to the actual excel file (first is preferred if you can replicate the actual error)

@bteplygin

This comment has been minimized.

Copy link
Author

@bteplygin bteplygin commented Feb 11, 2016

For example:

import pandas as pd
df = pd.DataFrame([["", 1, 100], ["", 2, 200], ["", 3, 300], ["", 4, 400]])
df.to_excel("test_excel.xls", index=False, header=False)
pd.read_excel("test_excel.xls", parse_cols=[0], header=None)
@jreback

This comment has been minimized.

Copy link
Contributor

@jreback jreback commented Feb 11, 2016

@bteblygin thanks!

PR to fix would be great!

@jreback jreback added this to the Next Major Release milestone Feb 11, 2016
BranYang added a commit to BranYang/pandas that referenced this issue Feb 17, 2016
This time I didn't touch the parser, just inside the excel.py itself.
@jreback jreback modified the milestones: 0.18.0, Next Major Release Feb 23, 2016
@jreback jreback closed this in 78d671f Feb 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.