-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
BUG: read_excel raising uncontrolled IndexError when header references non-existing rows #47399
Conversation
…s non-existing rows
pandas/io/excel/_base.py
Outdated
@@ -774,6 +774,11 @@ def parse( | |||
assert isinstance(skiprows, int) | |||
row += skiprows | |||
|
|||
if row > len(data) - 1: | |||
raise ValueError( | |||
f"Header index {row} references non-existing rows.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be helpful to report the number of rows? E.g.
f"header index {row} exceeds maximum index {len(data) - 1} of data.",
I also made the h lowercase to match the argument header
to read_excel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Thanks @phofl |
…s non-existing rows (pandas-dev#47399) * BUG: read_excel raising uncontrolled IndexError when header references non-existing rows * Fix issue number * Change message
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.