Topic 4 of 5 · 4 min read
Checking extracted data before use
Goal: Run count, total and spot checks on extracted data and locate the rows that fail them.
Extracted data is a draft until it passes four checks: the count, the total, a random sample and a scan for impossible values. Each check is simple, and together they catch most of what a model gets wrong.
Check yourself · 1 of 3
The source lists 123 invoices and the extracted table has 120 rows. What does this tell you?
Why it matters
An extraction can be 98 percent right and still harm you. With 500 rows, 2 percent is 10 wrong rows. They sit among 490 good ones, so reading the table gives no hint where they are. The checks below find them without rereading everything.
How to do it
- Count the rows. Count the items in the source (invoices, lines, people) and compare with the rows you got. A difference of one often means a repeated header or a lost row after a page break.
- Match a total. If the source prints a total, sum the same column and compare. If it does not, sum a column you can check another way, for example the number of units against the delivery note. A match proves the sum, not each row, because two errors can cancel out.
- Spot check a random sample. Pick 10 rows with a random method, not the first 10. Compare every cell with the source. If one has an error, double the sample, and if the errors keep coming, redo the extraction.
- Look for impossible values. Sort each column and read the top and bottom. Dates in the future or before the company existed, negative quantities, a price 100 times the others, an age of 212. Blank cells in a column that should never be blank. A spreadsheet filter or a pivot table makes this quick.
- Look for duplicates. Two rows with the same invoice number are either a real repeat or a double extraction.
- Keep a log. Write down the checks you ran and the result. Next week, you or a colleague can see what was verified.
Before and after
Before: The model said it extracted 120 rows. Looks fine, send to the finance team.
After: The source lists 123 invoices and the table has 120 rows: three are missing. The Amount column sums to 48,310, and the source total is 51,180, a gap of 2,870, which fits three missing invoices. Sorting Date shows one entry dated 2052. Fix those, then spot check 10 random rows.
What goes wrong
- Trusting the model's own count. A model may report the number of rows it meant to write.
- Checking only the first rows. Errors cluster where the file gets long or messy.
- Treating a matching total as proof. A swapped pair of digits in two rows can cancel out in the sum.
- Fixing by asking again. A second run can fix one row and break another. Compare against the source each time.
Examples
The gap that explains itself
A statement lists 123 invoices totalling 51,180. The extracted table has 120 rows and sums to 48,310. The missing 2,870 matches three invoices on page 4, which the model skipped after a page break. Counting and totalling found the problem without reading every row.
A date from 2052
A sorted Date column ends with 2052-03-14. The source says 2025-03-14. The model swapped two digits. A random sample of 10 rows would likely have missed it, but sorting the column shows it at once.
Key points
- Count the rows against the source before anything else; a gap of one is often a repeated header or a lost row.
- A matching column total proves the sum only; errors can cancel, so also check a random sample.
- Choose the sample at random, not the first rows, and widen it when you find an error.
- Sorting each column shows impossible values at the top and bottom, such as future dates or negative quantities.
- Write down which checks passed so the work can be repeated and trusted.
Common mistakes
- Believing the row count the model reports about its own output.
- Spot checking only the top of the table.
- Stopping after the total matches, even though errors can cancel.
- Re-running the extraction until it looks right instead of comparing with the source.
Check yourself · 2 of 3
The extracted Amount column sums exactly to the printed total. What can you conclude?
Check yourself · 3 of 3
You sort the Date column and the last value is 2052-03-14 in a file from 2025. What is the best next step?
Practice items, not counted towards your mastery.
Start here
- OpenRefine (opens in a new tab)ToolFree
A free desktop tool for clustering name variants and fixing a column in bulk, with every step recorded.
- Tabula: extract tables from PDFs (opens in a new tab)ToolFree
Free tool that pulls tables out of text-based PDFs without a language model, a useful cross-check.
- Vision (Claude docs) (opens in a new tab)DocsFree
What image and PDF reading can and cannot do, including limits on small text and tables.
More for this topic
- Working with missing data (pandas docs) (opens in a new tab)DocsFree
Shows how blanks and missing values are represented and counted in a table, useful for validation.