# Extract tables from a PDF to CSV in Python

> Python walkthrough: extract every table in a PDF to CSV files with the reductoai SDK and Reducto Parse. Works on scanned and multi-page tables.

Canonical: https://reducto.ai/cookbooks/pdf-tables-to-csv-python

Install the reductoai Python package, upload the PDF and call client.parse.run with formatting.table_output_format set to csv. Each table comes back as a Table block whose content is CSV text, which you write to a file. Add merge_tables to join tables that continue across pages.

## What you'll build

Synthetic 10-K excerpt (or your own file)

- pip install reductoai and set REDUCTO_API_KEY.
- Upload the PDF with client.upload.
- Call client.parse.run with table_output_format set to csv.
- Loop over result.result.chunks, then blocks, and write each Table block's content to a .csv file.

## Setup

Grab an API key from <a href="https://studio.reducto.ai" rel="noopener noreferrer" target="_blank">studio.reducto.ai</a> -> API Keys -> Create new API key, then set it and install the SDK:

```bash
export REDUCTO_API_KEY="your-api-key-here"
pip install reductoai   # or: npm install reductoai
```

## Step 1: Call `/parse`

The options that matter for this job:

- `formatting.table_output_format`: Table blocks contain CSV text.
- `formatting.merge_tables`: Joins consecutive tables with the same column count.
- `settings.model`: Handles dense and scanned tables.

```python
# pip install reductoai
from pathlib import Path
from reducto import Reducto

client = Reducto()  # reads REDUCTO_API_KEY

upload = client.upload(file=Path("annual-report.pdf"))
response = client.parse.run(
    input=upload.file_id,
    settings={"model": "r-1"},
    formatting={"table_output_format": "csv", "merge_tables": True},
)

count = 0
for chunk in response.result.chunks:
    for block in chunk.blocks:
        if block.type == "Table":
            count += 1
            Path(f"table_{count}.csv").write_text(block.content)
print(f"wrote {count} tables")
```

```javascript
// npm install reductoai

const client = new Reducto(); // reads REDUCTO_API_KEY

const upload = await client.upload({ file: fs.createReadStream("annual-report.pdf") });
const result = await client.parse.run({
  input: upload.file_id,
  settings: {
    model: "r-1",
  },
  formatting: {
    table_output_format: "csv",
  },
});
console.log(JSON.stringify(result, null, 2));
```

Or with curl:

```bash
# 1. Upload the file (or pass a public URL as "input" and skip this step)
curl -s https://platform.reducto.ai/upload \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -F file=@annual-report.pdf
# => {"file_id": "reducto://..."}

# 2. Run parse
curl -s https://platform.reducto.ai/parse \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": "reducto://FILE_ID",
  "settings": {"model": "r-1"},
  "formatting": {"table_output_format": "csv"}
}'
```

## Step 2: Read the result

On the sample (a synthetic 10-K excerpt), the job-specific part of the response:

```text
,Net sales,,,Operating income,,,Operating margin,
(in millions),FY2026,FY2025,% chg,FY2026,FY2025,% chg,FY2026,FY2025
Industrial Sensors,"1,842.6","1,661.3",10.9%,331.7,284.1,16.8%,18.0%,17.1%
Fluid Systems,"1,207.9","1,138.4",6.1%,168.0,152.6,10.1%,13.9%,13.4%
Aftermarket Services,644.2,607.5,6.0%,139.4,124.7,11.8%,21.6%,20.5%
```

Merged headers and parenthesized negatives come through as printed, one CSV per table.

[Full response format ->](https://docs.reducto.ai/parse/response-format)

## When to use something else

- **Parse with CSV tables**: to pull every table out of a document.
- **Extract**: when you need specific values in a fixed schema.

## Where this goes next

- [Free tool: PDF table to Excel](/tools/pdf-table-to-excel)
- [Multi-page table extraction](/guides/multi-page-table-extraction)
- [Python SDK docs](https://docs.reducto.ai/sdk/python/overview.md)

Try one PDF free, no signup, with the [PDF to CSV tool](/tools/pdf-to-csv) or the [PDF table to Excel tool](/tools/pdf-table-to-excel).
