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

Fix TableReader for tables without rows #2369

Merged
merged 3 commits into from
Mar 30, 2022
Merged

Conversation

bogdankostic
Copy link
Contributor

Previously, when passing tables to the TableReader that do not contain any rows, the TableReader was running into IndexError: index -1 is out of bounds for axis 0 with size 0. This PR fixes this bug by skipping tables that do not contain any rows.

CC @Timoeller

@bogdankostic bogdankostic added type:bug Something isn't working topic:tableQA labels Mar 29, 2022
Copy link
Member

@tstadel tstadel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! If you want you can place the check behind the declaration of the table variable. That might make the call to shape better understandable.
Besides that I trust you that a warning is the right "tool" in this situation. But I cannot really assess that. Just because I'm curious about that: In which situations does an empty table / dataframe occur? Is this a common case or is there something wrong with the "extraction" of the table?
In any case a small test to assert this behavior would be beneficial and could even help to understand in which situations the empty dataframes occur.

@bogdankostic
Copy link
Contributor Author

I added tests and will merge this PR once the CI has passed. We have seen a case where the ParsrConverter detects only the column header row of a table inside a PDF, resulting in a table that does not contain any rows.

@bogdankostic bogdankostic merged commit ca98891 into master Mar 30, 2022
@bogdankostic bogdankostic deleted the fix_table_reader branch March 30, 2022 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic:tableQA type:bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants