camelot-dev / camelot-dev/camelot
IndexError: list index out of range when specifying the area of table
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 546
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 3
Description
## File
[202.pdf](https://github.com/camelot-dev/camelot/files/5406925/202.pdf)
## Description
When specifying `table_areas`, I'm having the following error :
>Traceback (most recent call last):
File "", line 1, in
File "/home/remondn/.venv/prospector/lib/python3.6/site-packages/camelot/io.py", line 117, in read_pdf
**kwargs
File "/home/remondn/.venv/prospector/lib/python3.6/site-packages/camelot/handlers.py", line 172, in parse
p, suppress_stdout=suppress_stdout, layout_kwargs=layout_kwargs
File "/home/remondn/.venv/prospector/lib/python3.6/site-packages/camelot/parsers/lattice.py", line 411, in extract_tables
table = self._generate_table(table_idx, cols, rows, v_s=v_s, h_s=h_s)
File "/home/remondn/.venv/prospector/lib/python3.6/site-packages/camelot/parsers/lattice.py", line 332, in _generate_table
table = table.set_edges(v_s, h_s, joint_tol=self.joint_tol)
File "/home/remondn/.venv/prospector/lib/python3.6/site-packages/camelot/core.py", line 509, in set_edges
self.cells[L][J].bottom = True
IndexError: list index out of range
## Code to reproduce
With the given file :
```python
import camelot
camelot.read_pdf('202.pdf')
```
work as expected. But if I try to specify the table areas :
```python
import camelot
camelot.read_pdf('202.pdf', table_areas=['207,304,339,293'])
```
then I have the error.
## Expected behavior
As you can see from the PDF, this is not an actual table. I don't expect any meaningful content from this, **but I do expect no error**.
**Or should I assume if an exception is raised then it's not a table ?**
If it's the case, how to handle cases with several tables in one page and one fail ?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the reproduction in camelot/io.py with 202.pdf and the specified table_areas, then trace the reported call through parsers/lattice.py into core.py. Done means the non-table area no longer raises IndexError while the unrestricted extraction continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100