Free 40-page Claude guide — download today
October 6, 2026Samarth at CLSkillsClaudePDFData Extraction
Loading...

Convert PDF Tables to CSV with Claude: An Audit Workflow

Extract PDF tables with Claude using a copyable prompt, stable CSV columns, page references, and checks for missing rows, totals, and ambiguous values.

To convert a PDF table to CSV with Claude, define the columns before extraction, retain the source page for every row, and validate the result against the original document. A file that opens in a spreadsheet is not necessarily an accurate extraction.

Claude can interpret text and visual content in PDFs, including tables, but dense layouts and visual interpretation have limitations. The official PDF documentation describes those capabilities and recommends splitting large documents when needed. This guide focuses on an audit workflow you can use with a PDF-capable Claude interface; it does not assume that every interface has identical upload limits.

Decide whether an AI extraction is necessary

If the source system offers a clean CSV export, use that first. It usually preserves the underlying values more directly than reconstructing a table from a page layout. PDF extraction is useful when the PDF is the only available source or its tables require interpretation.

Before uploading, inspect three things: whether text can be selected, whether the table continues across pages, and whether each column has a clear heading. A scanned image, repeated page headers, and merged cells require different checks. Use a document you are permitted to process in the chosen service.

Define a schema before asking for rows

Suppose an illustrative supplier statement contains invoice numbers, dates, descriptions, currencies, and amounts. A useful extraction schema is:

ColumnRule
source_pagePhysical PDF page number, starting at 1
invoice_idText; preserve leading zeros
invoice_date_rawDate exactly as printed
descriptionPreserve meaningful punctuation
currencyPrinted code or symbol; blank when absent
amount_rawAmount exactly as printed
review_noteMissing, ambiguous, or merged-cell explanation

Keeping raw fields avoids a common error: silently converting an ambiguous date such as 03/04/2026 into the wrong day. Normalize values in a separate step after deciding the locale and required format.

Copy this extraction prompt

Extract the invoice table from the attached PDF.

Return CSV with exactly these columns:
source_page,invoice_id,invoice_date_raw,description,currency,amount_raw,review_note

Rules:
- One row per invoice line, not per visual line of wrapped text.
- Preserve invoice identifiers as text, including leading zeros.
- Preserve printed dates and amounts without interpreting their locale.
- Leave missing values empty. Do not invent values.
- Put uncertain readings and merged-cell assumptions in review_note.
- Exclude repeated page headers and subtotal/total rows from invoice rows.
- Quote fields containing commas, quotes, or line breaks correctly.
- Use physical PDF page numbers, starting at 1.

After the CSV, provide a separate audit summary:
row count per page, excluded totals, ambiguous cells, and pages not processed.
Do not describe the extraction as complete if any pages were omitted.

This is an original prompt template. Adjust the unit of a row for your document: an invoice, a line item, a transaction, or a measurement. That decision is more important than making the prompt sound elaborate.

Understand what a correct CSV row looks like

Here is an invented example, not data extracted from a real statement:

source_page,invoice_id,invoice_date_raw,description,currency,amount_raw,review_note
2,00042,03/04/2026,"Design, revision 2",USD,"1,250.00",Date locale requires review
2,00043,04/04/2026,Support,USD,300.00,

The description and amount contain commas, so those fields are quoted. The leading zeros are present in the CSV text, but spreadsheet software may still remove them during automatic import. Import invoice_id as text rather than assuming double quotes force a spreadsheet to preserve its type.

Validate structure separately from accuracy

This small Python check uses only the standard library. It checks the header, row width, and required page reference; it does not prove the numbers match the PDF.

import csv

expected = [
    'source_page', 'invoice_id', 'invoice_date_raw',
    'description', 'currency', 'amount_raw', 'review_note'
]
with open('extracted.csv', newline='', encoding='utf-8-sig') as f:
    reader = csv.reader(f)
    assert next(reader) == expected, 'Unexpected CSV header'
    count = 0
    for line_number, row in enumerate(reader, start=2):
        assert len(row) == len(expected), f'Wrong width at row {line_number}'
        assert row[0].isdigit() and int(row[0]) > 0, 'Missing page reference'
        count += 1
print(f'Structure checked: {count} rows')

Next compare row counts page by page. Review every row with a note and sample rows without notes. Check the beginning and end of each multi-page table, where repeated headers and carried-forward totals can create duplicates or omissions.

Reconcile totals without hiding exceptions

If the document supplies totals, compare like with like. Do not add multiple currencies together. Confirm whether the printed total includes tax, credits, discounts, or opening balances before treating a mismatch as an extraction error.

Keep a separate reconciliation sheet with the printed total, your calculated total, the difference, and an explanation. If a total does not reconcile, return to the source page. Asking the model to “make the numbers match” risks replacing an observable discrepancy with a plausible invention.

For difficult documents, process a small page range first. Once the output rules work, continue with explicit page ranges and preserve the same schema. Combine the results only after checking for overlap and missing pages.

Turn the workflow into a repeatable process

Save the schema, extraction prompt, and validation checks together. That package can become a Claude skill for your team. If the next step is sending structured results through an automation, use the n8n structured output guide to keep parsing and business validation separate.

FAQ

Can Claude convert a scanned PDF to CSV?

It may interpret a readable scanned table through PDF visual processing, but poor scans and complex layouts require careful review. Check uncertain cells against the original image instead of assuming the output is accurate.

Why did Excel remove leading zeros?

Spreadsheet import can infer numeric types even when a CSV field is quoted. Import identifiers as text and keep the original CSV available for comparison.

Is a valid CSV enough to automate the next step?

No. Valid CSV only establishes a usable structure. Check completeness, source values, duplicate handling, and any business rules before downstream use.

Loading...