camelot-dev / camelot-dev/excalibur
ERROR:root:list index out of range (only when using "LATTICE" with CUT TEXT option)
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 238
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I have a problem to extract some tables from one file using "LATTICE" method with CUT TEXT option.
I have extracted from the original PDF one page that is quite stubborn
[page21.pdf](https://github.com/camelot-dev/excalibur/files/3850208/page21.pdf)
I always get this message:
```
ERROR:root:list index out of range
Traceback (most recent call last):
File "c:\pve\datas\lib\site-packages\excalibur\tasks.py", line 110, in extract
t = parser.extract_tables(filepaths[p])
File "c:\pve\datas\lib\site-packages\camelot\parsers\lattice.py", line 412, in extract_tables
table = self._generate_table(table_idx, cols, rows, v_s=v_s, h_s=h_s)
File "c:\pve\datas\lib\site-packages\camelot\parsers\lattice.py", line 354, in _generate_table
indices = Lattice._reduce_index(
File "c:\pve\datas\lib\site-packages\camelot\parsers\lattice.py", line 160, in _reduce_index
if t.cells[r_idx][c_idx].hspan:
IndexError: list index out of range
```
When I am not using CUT TEXT (false) then extraction is successful but the table is not correctly parsed (fields which should be separated are connected and vice versa)
Contributor guide
Research direction
Start with the attached page21.pdf and reproduce the failure using LATTICE with CUT TEXT enabled. Read camelot/parsers/lattice.py, especially _generate_table and _reduce_index, then compare the behavior with CUT TEXT disabled. Done means the reported page no longer raises IndexError and its table is parsed correctly with CUT TEXT enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100