How to Convert a PDF to CSV Without Losing Table Structure

Convert a PDF table to CSV. Keep rows and columns correct. Learn how to process digital and scanned PDFs, merged cells, and complex tables.

PdfParse Team

You can convert a PDF to CSV. However, a correct CSV file needs more than text extraction. It must keep each value in the correct row and column.

This guide gives you a controlled process. You will extract one invoice table. You will then check the CSV file before you use it.

The result that you must get

The source PDF has this table:

DateInvoiceVendorAmount
2026-06-03INV-1042Northwind Office Supply297.00
2026-06-07INV-1048Contoso Shipping84.50

The CSV output must have the same records:

date,invoice_number,vendor,amount2026-06-03,INV-1042,Northwind Office Supply,297.002026-06-07,INV-1048,Contoso Shipping,84.50

Do not accept an output that only looks similar. Check the number of rows. Check the column names. Check the value in each cell.

1. Identify the PDF type

First, determine if the PDF has a text layer.

Try to select one word in the PDF viewer. If you can select the word, the PDF is usually a digital PDF. If you can only select the full page, the page is probably an image.

Use OCR for a scanned PDF. OCR changes page images into text that the extraction system can process.

The PDF type affects the result:

PDF typeMain riskRequired control
Digital PDFIncorrect reading orderCheck column order
Scanned PDFOCR character errorsCheck dates, numbers, and codes
Mixed PDFDifferent behavior on each pageTest all page types

Do not assume that a PDF is digital because it looks clear. A clear page can still be one large image.

2. Define the required result

Define the result that you need before you start the conversion. This step is a data-planning step. It is not a screen in the converter.

For the sample invoice table, use these columns:

ColumnTypeRule
datedateUse YYYY-MM-DD
invoice_numbertextKeep the value as printed
vendortextKeep the complete vendor name
amountnumberRemove the currency symbol

PdfParse infers the CSV schema from the first uploaded PDF. Use the result table to confirm that the inferred columns match your required result.

Use one name for each concept in downstream work. Do not use amount, total, and value for the same field.

Keep codes as text. This rule prevents a spreadsheet from removing leading zeros. For example, the code 00142 must not become 142.

3. Convert the PDF to CSV

Open the PDF to CSV converter. Then do these steps:

  1. Complete the security check if you use the temporary converter.
  2. Select Open converter.
  3. Select Upload PDF in the empty workspace.
  4. Select one or more PDF files.
  5. Wait while PdfParse infers the CSV schema from the first PDF.
  6. Wait while the upload and extraction start automatically.
  7. Review the extracted rows in the Results tab.
  8. Select a row to open its source PDF on the right.
  9. Select a dataset tab when PdfParse creates related CSV tables.
  10. Select Download CSV.

The temporary converter accepts up to three PDF files and five pages in total. The temporary workspace expires after two hours.

PdfParse does not show a manual column-mapping step in this workflow. It infers the document structure. It can create one dataset or related datasets.

Use a small sample first. Include a file with the most difficult table layout. Do not process the full file set until the sample result is correct.

For scanned documents, compare small characters carefully. OCR systems can confuse 0 and O. They can also confuse 1, I, and l.

4. Keep table rows together

A PDF stores visual positions. It does not always store a real table. A description that wraps to a second line can cause an incorrect new row.

Use these rules:

  • One source record must become one CSV row.
  • A wrapped description must stay in the same record.
  • A page header must not become a data row.
  • A repeated table header must not become a data row.
  • A page total must not become a line item.

For example, this source cell contains one description:

Annual equipment maintenancefor the Kingston office

The CSV must keep it in one field:

description,amount"Annual equipment maintenance for the Kingston office",450.00

Quotes are necessary when a field contains a comma, a quotation mark, or a line break. A correct CSV writer adds these quotes.

5. Handle merged cells

Merged cells can hide the relationship between values.

For example, one vendor name can apply to three invoice rows. The vendor name can appear only in the first visual row.

Choose one of these output rules:

  1. Repeat the vendor name in each CSV row.
  2. Put the vendor in a parent table and put the invoices in a child table.

Use the first rule for a flat CSV file. Use the second rule when you need a relational database.

Do not leave the second and third vendor cells empty if the blank cells mean “same as above.” Empty values lose information outside the visual table.

6. Validate the CSV file

Do not validate only the first row. Use these checks:

Check the structure

  • Count the source records.
  • Count the CSV rows.
  • Confirm that each row has the same number of columns.
  • Confirm that all required headers are present.

Check the values

  • Compare dates with the source PDF.
  • Compare the largest and smallest amounts.
  • Check negative values.
  • Check blank cells.
  • Check codes that have leading zeros.
  • Check descriptions that contain commas.

Check the totals

If the source has a total, compare it with the sum of the CSV values.

import csvfrom decimal import Decimalwith open("invoices.csv", newline="", encoding="utf-8") as file:    rows = list(csv.DictReader(file))total = sum(Decimal(row["amount"]) for row in rows)print(total)

Use Decimal for money. Do not use binary floating-point values for financial checks.

7. Know the limits

Some pages need manual review. Review these inputs carefully:

  • handwriting
  • low-resolution scans
  • rotated pages
  • tables without visible column boundaries
  • tables that continue across pages
  • nested tables
  • merged cells with an unclear meaning
  • password-protected PDFs

If a PDF has a password, remove the password only when you have permission. Then upload the unlocked copy.

Use CSV when the data is flat

CSV is a good output when you need rows for a spreadsheet, an import tool, or a simple analysis.

Use JSON when you need nested objects or arrays. Use SQLite when you need related tables and SQL queries.

To start, open the PDF to CSV converter. You can also review the PDF document parser, the API documentation, and pricing.