🧠 AI Learning Hub

Hub › Lessons › Extra lesson

Extra lesson · Money adminAbout 20 minutes

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)

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.

Prompt: copy a PDF table and prove no rows were lost
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.

  1. 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.
  2. Type the opening balance from the PDF into cell J1.
  3. 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)
  4. Put this in G3 and fill it down to the last row:
    =ROUND(E2-C3+D3-E3,2)
  5. 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.

Reply from the first run
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

Watch out for

Next step

How we checked this lesson