Hub › Lessons › Extra lesson
Extract a table from a PDF with AI, then check no rows are missing
Your bank statement or invoice list often comes only as a PDF. AI can copy the table into a spreadsheet in a minute. The risk is not a wrong number you can see. It is a row that quietly goes missing, because you cannot spot what is not there. This lesson gives you a tested prompt that copies every row and checks itself against the totals printed in the PDF, plus two spreadsheet formulas so you can check the result yourself.
What you will be able to do: turn a PDF table into a clean spreadsheet, and prove with the PDF's own totals and running balance that every row came across, or see exactly where one is missing.
Step 1: Check the PDF first (2 minutes)
- Can you select the text? Open the PDF and try to highlight a few words. If you can, it is a text PDF and works best. If it is a photo or a scan, results will be weaker. ChatGPT's help page says image-only PDFs are not supported.
- Find the printed checks. Look for an opening balance, a closing balance, "Total" lines or a count such as "23 invoices". These are what prove nothing was lost. Most bank statements have a running balance on every row, which is the strongest check of all.
- Keep it short. One statement or one month at a time. Claude's help page says it reads text and images in PDFs up to 100 pages, and only the text in longer ones.
- Mind what you upload. A statement holds your account details and your customers' names. Use an assistant and plan you are comfortable sharing that with, and never paste passwords or full card numbers.
Step 2: Ask AI to copy the table and check itself
Open a new chat in Claude or ChatGPT, attach the PDF, and paste this prompt.
I attached a PDF that contains a table (for example a bank statement or an invoice list). Copy every row of that table into a clean table I can paste into a spreadsheet. Then prove no rows were lost. Rules: 1. Copy values exactly as printed. Do not fix, round, translate or guess anything. If a value is unreadable, write [UNREADABLE]. 2. One table row = one line, even if its description wraps onto two lines in the PDF. Join the wrapped text with a space. 3. Do NOT include headers, opening or closing balances, "carried forward" lines, subtotals or totals as rows. List them separately under "Printed figures". 4. Add a column "Page" with the page number each row came from. 5. If the same row seems to appear twice, keep both and mention it under "Check these rows". Reply in this order: A. Rows per page: a short list "Page 1: n rows", and the total number of rows. B. The table, as CSV inside a code block, with the same columns as the PDF plus Page. C. Printed figures: every opening balance, closing balance, subtotal and total printed in the PDF, word for word, with its page. If there are none, write "None printed". D. Checks, each with PASS or FAIL and the numbers: - If the PDF prints a total or subtotal: add up that column from your rows and compare. - If the PDF prints a count (for example "23 invoices"): compare it with your row count. - If there is a running balance: for every row check previous balance - money out + money in = this balance. List every row where it does not match. If a check cannot be done, write "Not possible: " and the reason. E. Check these rows: anything you were unsure about. If none, write "None".
Read section D first. If every check says PASS, carry on. If one says FAIL, go to section E: it names the row where the numbers stop adding up. Open the PDF at that page and look.
Step 3: Check it yourself in a spreadsheet (5 minutes)
The AI's own checks are useful, but they are still the AI marking its own work. This step takes two formulas and does not depend on the AI.
- Copy the CSV from section B into a plain text file and save it as
statement.csv. In Google Sheets, use File › Import › Upload. In Excel, open the file directly. - Type the opening balance from the PDF into cell J1.
- For a bank statement with columns Date, Description, Withdrawal, Deposit, Balance, Page (A to F), put this in G2:
=ROUND($J$1-C2+D2-E2,2) - Put this in G3 and fill it down to the last row:
=ROUND(E2-C3+D3-E3,2) - Count the rows that do not add up, in J2:
=COUNTIF(G2:G500,">0")+COUNTIF(G2:G500,"<0")
Every value in column G should be 0, and J2 should be 0. A number other than 0 sits on the row just after a missing or mistyped row, and it equals the missing amount. For a list without a running balance, such as invoices, compare =SUM(D2:D500) with the printed total and =COUNTA(A2:A500) with the printed count, using your own column letters.
Worked example
We made a two-page bank statement for a made-up Punggol home bakery and left one deposit row out of the PDF on purpose, while the printed totals and balances still included it. The bank, business, payees and amounts are illustrative. This is what the prompt returned.
Output (as returned, table shortened)
Shown word for word from the first run, except that we cut 26 of the 33 table rows for length where it says so.
I read both pages of the statement and copied 33 rows. Two checks fail: the deposits column adds up to 113.77 less than the printed "Total deposits", and the running balance jumps by the same 113.77 on the 10 OCT row. The rows are copied as printed; I didn't change any value to make the numbers agree. **A. Rows per page** - Page 1: 18 rows - Page 2: 15 rows - **Total: 33 rows** **B. Table** ```csv Date,Description,Withdrawal,Deposit,Balance,Page 01 OCT,PAYNOW FROM KOPI CORNER,,71.70,"1,592.10",1 01 OCT,FAST PAYMENT FROM TAN BAKES,,39.90,"1,632.00",1 02 OCT,GIRO SP SERVICES,185.86,,"1,446.14",1 [ROWS CUT HERE FOR LENGTH: 7 more rows] 09 OCT,GIRO SP SERVICES,248.11,,"2,262.91",1 10 OCT,PAYNOW FROM KOPI CORNER,,358.12,"2,734.80",1 11 OCT,NOTION LABS,59.12,,"2,675.68",1 [ROWS CUT HERE FOR LENGTH: 19 more rows] 28 OCT,PACKAGING DEPOT PTE LTD,207.91,,"1,646.53",2 ``` **C. Printed figures** - Page 1: "Opening balance 1,520.40" - Page 1: "Balance carried forward 2,245.59" - Page 2: "Total withdrawals 2,850.82" - Page 2: "Total deposits 2,976.95" - Page 2: "Closing balance 1,646.53" **D. Checks** - **Total withdrawals: PASS.** My rows add up to 2,850.82 (1,262.65 on page 1 plus 1,588.17 on page 2), which matches the printed 2,850.82. - **Total deposits: FAIL.** My rows add up to 2,863.18 (1,874.07 on page 1 plus 989.11 on page 2). The printed total is 2,976.95, which is 113.77 more. - **Row count: Not possible.** The PDF doesn't print a count of transactions. - **Running balance: FAIL on 1 row out of 33.** - 10 OCT, PAYNOW FROM KOPI CORNER: 2,262.91 + 358.12 = 2,621.03, but the printed balance is 2,734.80. That's 113.77 more. - The other 32 rows all match. - The page 1 carried-forward figure (2,245.59) matches the last row on page 1 and the starting point on page 2. - The closing balance (1,646.53) matches the last row. - **Overall: FAIL.** Opening balance − printed total withdrawals + printed total deposits = 1,520.40 − 2,850.82 + 2,976.95 = 1,646.53, which matches the closing balance. Using my rows instead gives 1,532.76, which doesn't match. **E. Check these rows** - **10 OCT, PAYNOW FROM KOPI CORNER, deposit 358.12.** Both failed checks are off by exactly 113.77, and that gap starts on this row. Either the deposit amount was printed wrong (the balance suggests 471.89) or a deposit of 113.77 is missing from the PDF. The page image clearly shows 358.12. Please compare this row with your bank's records. - **Rows that wrapped onto two lines in the PDF, which I joined into one line:** - 05 OCT, PACKAGING DEPOT … ORDER BATCH SPECIAL (page 1) - 19 OCT, NTUC FAIRPRICE PUNGGOL … ORDER BATCH SPECIAL (page 2) - **Possible duplicates: none.** Some payees appear more than once, including on the same day (two on 24 OCT), but the amounts are all different.
It found the gap, put it on the right row, and did not change any number to make the totals agree. Our spreadsheet check on the same CSV flagged the same row: column G showed -113.77 on the 10 OCT row and 0 everywhere else.
What the test showed
- No rows lost on complete PDFs. On three made-up PDFs (a 2-page and a 3-page statement with 34 and 57 rows, and a 2-page invoice list of 23 rows with page subtotals), all nine runs copied every row with every amount and balance matching what was printed.
- Totals were not counted as rows. Opening balances, "carried forward" lines and page subtotals went under "Printed figures", not into the table, in all nine runs.
- Wrapped descriptions were joined. Descriptions that ran onto a second line in the PDF came out as one row each time.
- A missing row was caught every time. In three of three runs on the statement with a row left out, the deposits total and the running balance both failed, and section E named the 10 OCT row and the 113.77 gap.
- The spreadsheet check works on its own. Removing one row from a correct CSV made column G show the missing amount on the next row, and the count of rows to check went from 0 to 1.
Watch out for
- A PASS only covers what the PDF prints. If there is no total, count or running balance, the AI cannot prove completeness. Count the rows on each page yourself and compare with section A.
- Scans and photos are harder. We tested clean text PDFs only. With a scan, expect more [UNREADABLE] values and check more rows by eye.
- Copied is not the same as correct. The prompt copies what the bank printed. If the bank made a mistake, the checks show where the numbers disagree. They do not tell you which side is right.
- Check the dates before you sort. Statements often print "10 OCT" with no year. Add the year before you sort or total by month.
Next step
Keep this prompt in Notion (free)
This prompt and four others from our lessons are in the free AI Working Notes kit: one Notion page with a business memory, a prompt library and the checks for each prompt.
See the free kitSort the rows into categories
Once the table is complete, use the categorise bank transactions lesson to put each row into your own expense categories.
Go to the categorise lessonThen review the month
With the rows in a sheet, the monthly cash review prompt turns them into a short summary of what came in and went out.
Go to the cash review lessonHow we checked this lesson
- On 19 Nov 2026 we made four illustrative text PDFs with a script: statement A (2 pages, 34 rows, two wrapped descriptions), statement B (3 pages, 57 rows, three wrapped descriptions), invoice list C (2 pages, 23 rows, page subtotals and a printed count) and statement D (statement A with one deposit row left out of the PDF, while the totals and balances still included it).
- We ran the prompt with Claude Code 2.1.327 in print mode, reading each PDF with its own file reader and no other tools: three runs each on A, B, C and D. The model never saw our answer file.
- A separate script compared every table with the rows we had generated: row count, every amount and balance, descriptions, and no total or balance lines inside the table. All nine runs on A, B and C passed. We also fed the script two broken outputs (one row removed, one balance changed) and it failed both. We read all twelve replies, which is where the D results above come from.
- We tested the spreadsheet formulas in LibreOffice Calc on the CSV from a correct run with one row removed, and on the CSV from the first D run. Both flagged the row after the gap. We did not test the import in Google Sheets or Excel for this lesson.
- The file limits above come from Upload files to Claude and ChatGPT's File Uploads FAQ, read on 19 Nov 2026. Limits change, so check them before you rely on them.
- We tested one assistant on clean, made-up PDFs. AI output varies by tool, model and document, so run the checks on every PDF you convert.
- Where the idea came from: a Latent Space episode in which Reducto's CEO explains that general AI models can drop table rows without saying so, and why tracing each value back to the page matters (Cooking with Reducto's CEO: Why PDFs Still Break AI). The prompt, checks and tests here are our own.
- Last reviewed: 19 November 2026.