Tabula extracts tables in two ways: the lattice method suits tables with ruling lines separating the cells, as in a PDF of an Excel spreadsheet, while the stream method suits tables without grid lines. Picking the wrong method merges or splits columns, so try both and check which one lines up.
What you need
- Tabula installed with Java
- A text-based PDF containing a table
- A note of the column count in the source table
Step 1: Extract with the default method
Import the PDF in Tabula, select the table, preview the extraction with the default method, and count the columns in the preview.
Step 2: Try the other method
Run the extraction again with the other method, lattice if the first was stream and stream if the first was lattice, and preview it too.
Step 3: Compare the previews
Compare both previews with the PDF table: the right method gives the correct column count and keeps each value in its own cell.
Worked example: synthetic method comparison on a ruled table
The table below is a synthetic example. It shows the expected result of comparing extraction methods; no table was extracted.
| Method | Columns in preview | Values in right cells |
|---|---|---|
| Stream | 3 | No – two columns merged |
| Lattice | 5 | Yes – all values placed |
| Source table | 5 | Reference |
Expected result (UNTESTED). the stream method gives 3 columns with two merged, while the lattice method gives the correct 5 columns with every value in its own cell. Use lattice for this ruled table. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- The correct method depends on whether the page contains a table grid; without borders the lattice method may not recognise the table.
- Multiple tables with different column counts on the same page can confuse detection.
- Tabula can export CSV, TSV, HTML or JSON; CSV is the usual choice for a spreadsheet.
