Skip to content
mentoor

Topic 1 of 5 · 4 min read

Pulling tables from PDFs and screenshots

Goal: Extract a table from a PDF or screenshot into columns and verify it against the source on totals and a sample of rows.

A model can turn a PDF or a screenshot of a table into rows and columns, but you only own the result after you have checked it against the source. The conversion is fast. The errors are small, and they look like real data.

Check yourself · 1 of 3

A supplier PDF has text you can select and copy. Which approach makes a misread digit least likely?

Choose one answer

Why it matters

Reports, invoices and bank statements often arrive as PDFs or pictures. Retyping 200 rows takes an afternoon. Pasting the file into ChatGPT, Claude, Gemini or Copilot takes a minute. But a model reads a picture of numbers, it does not copy them. A 6 can become an 8, a decimal point can slip, and a row can vanish.

How to do it

  1. Pick the right tool for the file. If the PDF has real text (you can select and copy words), a table extractor such as Tabula reads the text directly, with no guessing. If the file is a scan or a photo, use a model that can see images, and expect more errors.
  2. Name the columns before the model does. Write them in the prompt, in order, for example: Date, Description, Amount, Balance. Say what to do with a cell that is empty or unreadable: leave it blank, do not guess.
  3. Work in small pieces. One page at a time gives better results than 40 pages at once. Long files make models skip rows near the end.
  4. Ask for the table as plain rows, such as CSV or a markdown table, so you can paste it into a spreadsheet.
  5. Check it. Compare the row count with the source. Add up a numeric column and match it to the total printed on the page. Then pick five rows at random and compare every cell by eye.

Before and after

Before: Turn this PDF into a spreadsheet.

The model chooses its own column names, may merge two columns into one, and quietly skips what it cannot read.

After: This is page 2 of a supplier statement. Extract the table into four columns: Date (as YYYY-MM-DD), Invoice no., Amount, Status. One row per invoice. If a cell is unreadable, leave it empty and add the word CHECK in a fifth column called Note. Do not guess any digits. Return CSV only.

What goes wrong

  • Merged cells. A label that spans three rows gets attached to only one of them, or repeated wrongly.
  • Page breaks. A table that continues on the next page may repeat its header as a data row, or lose the first row of the new page.
  • Misread digits. Low-quality scans turn 1 into 7 and 5 into 6. The table still looks tidy, so only the total check shows it.
  • Silent repair. Some models "fix" a number that looks odd, so the extracted value no longer matches the source.

Examples

A total that does not match

A model extracts 38 invoice rows from a supplier statement. The printed total at the bottom is 14,260.50, but the extracted Amount column adds up to 14,860.50. Comparing rows to the page shows one invoice of 1,260.50 was read as 1,860.50. The total check found an error that looked perfectly normal in the table.

The header that became data

A statement runs over two pages and the header row repeats at the top of page 2. The extracted table has a row with the words Date, Invoice no. and Amount in the middle. Counting rows (one more than the source) is what catches it.

Key points

  • A text-based PDF can be read directly by a table extractor; a scan or photo needs a vision model and more checking.
  • Name the columns and their order in the prompt, and tell the model to leave unreadable cells blank.
  • Work one page or a few pages at a time; long files lose rows.
  • Check the row count, one column total against the printed total, and a random sample of rows.
  • Merged cells, page breaks and misread digits are the usual failures, and the output looks tidy even when they happen.

Common mistakes

  • Pasting a 40-page PDF in one go and trusting the row count the model reports.
  • Letting the model choose the column names and order.
  • Checking only that the table looks right, not adding up a column.
  • Using a vision model on a PDF that has real text, when a text extractor would not guess at all.

Check yourself · 2 of 3

A model returns 38 invoice rows. The page says the total is 14,260.50, but the extracted Amount column adds to 14,860.50. What is the best next step?

Choose one answer

Check yourself · 3 of 3

Which instruction in an extraction prompt best reduces invented digits?

Choose one answer

Practice items, not counted towards your mastery.

Start here