Davy
A circular field of symmetric navy dots with a blue accent pattern at the center
AI Transformation

How to Extract Reliable Data From PDFs and Excel

AI can pull data from PDFs and spreadsheets. Reliable extraction needs a schema, source references, validation rules and a tested sample. Here is the setup.

In brief

  • Reliable extraction means correct values, each traceable to its page or cell, checked by rules, with exceptions sent to a person.
  • Define the fields and the "not found" behavior first. Let the model read and let formulas or code do the arithmetic and the checks.
  • Test on a gold set of real documents with human-verified values, and measure accuracy field by field.

Pulling data out of PDFs and spreadsheets is the kind of task that looks effortless in a demo and causes quiet damage in production. A model reads an invoice and returns a clean table, and nobody notices that the total is wrong in one document out of fifty. Reliable extraction is not a better prompt. It is a small system: a definition of what you want, a way to trace every value, rules that check the results, and a path for the cases that fail.

Know what you are feeding it

InputTypical problemWhat helps
Text-based PDFTables that break across pages, multi-column layoutsAsk for page references, check table continuity
Scanned PDF or photoMisread digits, skewed pages, stamps over textVerify key figures against the image, flag low-quality scans
Excel with data tablesMerged cells, hidden rows or sheets, several tables per sheetHave the tool list sheets and structure before extracting
Excel with formulasFormula and displayed value differ, external linksRead both value and formula, note any links
Mixed packetSeveral document types in one fileClassify each page first, then extract by type

Define the schema first

Write down the fields you need before anyone runs a document through. For an invoice: vendor name, invoice number, invoice date, due date, currency, line items (description, quantity, unit price, amount), subtotal, tax and total. For each field, state its type, its format, whether it is required, and any allowed values. Then state what to do when a field is absent. The instruction should be "return nothing for this field and say it was not found," because a model left to its own devices will often fill gaps with something plausible.

Make every value traceable

Each extracted value should carry its source: the page number and the text it came from, or the sheet and cell. This is what makes review fast. A reviewer should be able to see a value, click or look straight to where it came from, and confirm it in seconds. A table of numbers with no location data is a table you have to take on faith.

Validate with rules, not hope

Do not ask the model to be careful. Check the results with rules that do not depend on it. A short list covers most documents.

  • The line amounts add up to the subtotal, and the subtotal plus tax equals the total.
  • Quantity times unit price equals the line amount.
  • Dates are plausible and in sensible order, with the due date after the invoice date.
  • The invoice number is not a duplicate of one already processed.
  • The currency is recognized and the vendor exists in your vendor list.
  • For spreadsheets, row counts and column totals match the source, and key columns pass a cross-foot.

Let the model read, and let a formula or a script do the arithmetic. A language model is a poor calculator and an excellent reader. Putting each in its own role makes the whole system more reliable.

Send exceptions to a person

Documents that fail a check, or where the model reports low confidence, go to a human queue. Documents that pass go through. Show reviewers the failing check and the source location so a decision takes seconds. Track the exception rate by document type and by vendor. A vendor whose invoices fail constantly is telling you something about their format, and so is a rising rate after a change you made.

Test on a gold set

Before anyone relies on the system, assemble thirty or so real documents of the kinds you will process, and have a person record the correct values for each field. Run the extraction and score it field by field, not document by document, because an overall accuracy figure hides the fact that a few fields, usually amounts and dates, are the ones that matter. Look at the failures and fix the schema or the instructions. Re-run the set after every change, and add new problem documents to it as they appear.

Spreadsheet specifics

Spreadsheets deserve their own checks. Ask the tool to describe the structure first: sheets, hidden rows and columns, merged cells and where each table begins. Watch for units and signs in the header ("in thousands," "credits shown as negatives"). Dates stored as text, numbers stored as text and percentages stored as fractions all produce errors that look like valid data.

Where the results go

Do not send extracted data straight into your accounting or operations system. Land it in a staging area, let the checks and the reviewer clear it, and then import it with a record of who approved what. Davy's chat and documents page shows documents being uploaded and analyzed with answers that point back to their sources, and the integrations page explains how Davy approaches connections to the systems where the data finally lives.

About This Post

Frequently asked questions.

What accuracy should we expect from AI extraction?

There is no honest single number. It depends on the document type, the scan quality and how well you define the fields. Measure it on your own gold set, field by field, and set a target for the fields that matter most, such as amounts.

Do we need to run OCR before sending scans to an AI tool?

Not necessarily, since many tools read images directly. Whatever route you use, check key figures against the original image, because misread digits are the most common failure in scans.

How do we handle tables that continue across pages?

Ask the tool to report page ranges for each table, and add a validation rule that the total across pages matches the stated total. A mismatch means a row was missed or doubled.

Can AI extract data from handwritten documents?

Sometimes, and with lower reliability. Treat handwritten fields as low confidence by default, route them to review, and track accuracy separately.

Next Step

Get in touch with us.

Secure AI that helps you speed up your work.