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
Bug IO Excel read_excel, to_excel
Milestone

Comments

@bteplygin
Copy link

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
Copy link
Contributor

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)

@jreback jreback added Bug IO Excel read_excel, to_excel labels Feb 11, 2016
@bteplygin
Copy link
Author

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
Copy link
Contributor

jreback commented Feb 11, 2016

@bteblygin thanks!

PR to fix would be great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO Excel read_excel, to_excel
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants