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

ValueError in modela/tables.py #358

Closed
michaelstellanar opened this issue Jun 21, 2024 · 2 comments
Closed

ValueError in modela/tables.py #358

michaelstellanar opened this issue Jun 21, 2024 · 2 comments
Labels
bug Something isn't working needs follow up

Comments

@michaelstellanar
Copy link

In one of my input pdf files, the following is thrown:

File "/home/michaelt/Work/sandbox_gradio/inference/lib/python3.12/site-packages/unstructured_inference/models/tables.py", line 667, in fill_cells
table_rows_no = max({row for cell in cells for row in cell["row_nums"]})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: max() iterable argument is empty

Debugging shows that cells array is, indeed, [].

Proposed fix:

table_rows_no = max({row for cell in cells for row in cell["row_nums"]}, default=0)
table_cols_no = max({col for cell in cells for col in cell["column_nums"]}, default=0)

It fixed my problem.

@christinestraub christinestraub added bug Something isn't working needs follow up labels Jun 21, 2024
christinestraub added a commit that referenced this issue Jun 21, 2024
This PR will address
#357 and
#358.

### Summary
- add logic to validate the input parameter to the fill_cells()
function. Now, the function checks if the input is a list of
dictionaries before processing.
- correct type hint for parameter `cells` in
`table_cells_to_dataframe()`
@christinestraub
Copy link
Contributor

Hi @michaelstellanar, Addressed on #359. You'll need to upgrade unstructured-inference to 0.7.36.

@christinestraub
Copy link
Contributor

Closing this since it's assumed to be resolved, but feel free to reopen if you're still having this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs follow up
Projects
None yet
Development

No branches or pull requests

2 participants