Camelot’s lattice mode reads tables that have visible ruling lines, using the lines to find the rows and columns. It is the right mode for bordered tables, but it still needs a check: a missing line or a merged cell can shift the whole grid, and the error only shows when you compare the output with the page.
What you need
- Python with Camelot installed
- A PDF with a ruled table
- The table as printed on the page, to compare against
Step 1: Extract with lattice mode
Run camelot.read_pdf(“file.pdf”, flavor=”lattice”) and export the first table to a CSV file. Lattice is the default flavour and suits tables with ruling lines.
Step 2: Read the parsing report
Check the table parsing report for its accuracy, whitespace, and confidence values. A low accuracy score means the grid was guessed badly.
Step 3: Compare every cell with the page
Open the CSV next to the PDF page and check each cell value, row by row. Pay attention to the first and last rows, where missing lines cause the most errors.
Worked example: synthetic lattice extraction of a 4 by 3 sales table
The table below is a synthetic example. It shows the expected result of extracting a ruled table; no extraction was run.
| Cell | On the page | In the CSV |
|---|---|---|
| Row 1, Product | Widget A | Widget A |
| Row 1, Qty | 12 | 12 |
| Row 2, Product | Widget B | Widget B |
| Row 2, Total | 480 | 480 |
Expected result (UNTESTED). all 4 checked cells match the page, and the parsing report shows high accuracy, so the lattice extraction is trustworthy for this table. Still check the remaining cells before using the CSV. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- Lattice mode needs ruling lines; a table with no visible lines will extract as a single cell.
- Camelot reads only the first page by default, so set the pages argument for a table on another page.
- A table split across pages is extracted as separate tables unless the pages are joined first.
