How to extract data from many PDFs into one Excel sheet

Updated · Tested with Python 3.13, pypdf 7.2.0, openpyxl 3.1.5

In short

For tables inside PDFs, use Excel's own Data > Get Data > From File > From PDF. For particular values from each file, such as a number, a date and a total, either write a short Python script that reads each PDF and writes one row, or upload the folder to a service that returns one spreadsheet with a row per file and a column per value.

You have a folder of PDFs of the same kind, such as supplier invoices, certificates or registry extracts, and you want one spreadsheet: a row for each file and a column for each value. There are three ways to get there, and the right one depends on whether the PDFs contain tables or scattered values, and on whether you write code.

MethodGood forNeeds
Excel's own "From PDF"Tables inside PDFsExcel for Microsoft 365 on Windows
A Python scriptNamed values, full controlSomeone who writes Python
Upload to a serviceNamed values, no codeAn account

The examples use four company extracts: harbor-lane.pdf, northgate-freight.pdf, bayview-holdings.pdf and shifted-layout.pdf.

Method 1: Excel's "From PDF"

Excel can open PDFs itself: Data > Get Data > From File > From PDF. It finds the tables in the file and loads the one you pick into a sheet. For a whole folder, use Data > Get Data > From File > From Folder and combine the files.

This works well when each PDF really contains a table and you want that table. It is the wrong tool when the values you want are scattered over the page, such as a number at the top and a total at the bottom, because it does not pull out single values and give them names. It also reads only PDFs with text in them, not scans.

Method 2: a Python script

For named values, a short script does the whole job: read each file, pick out the values, write one row.

Shell
pip install pypdf openpyxl
Python
import glob
import os
import re

from openpyxl import Workbook
from pypdf import PdfReader

def read(path):
    text = PdfReader(path).pages[0].extract_text()

    def get(pattern):
        match = re.search(pattern, text)
        return match.group(1) if match else None

    capital = get(r"Share capital ([\d,.]+)")
    return {
        "File": os.path.basename(path),
        "Company name": get(r"Company name (.+)"),
        "Company number": get(r"Company number ([\d-]+)"),
        "Status": get(r"Status (\w+)"),
        "Registered": get(r"Registered (.+)"),
        "Share capital": float(capital.replace(",", "")) if capital else None,
    }

rows = [read(path) for path in sorted(glob.glob("extracts/*.pdf"))]

workbook = Workbook()
sheet = workbook.active
sheet.append(list(rows[0].keys()))
for row in rows:
    sheet.append(list(row.values()))
workbook.save("extracts.xlsx")

for row in rows:
    print(row["File"], row["Company number"], row["Share capital"])
Output
bayview-holdings.pdf 51-377102-9 100.0
harbor-lane.pdf 51-482913-6 1250.5
northgate-freight.pdf 51-509871-2 40000.0
shifted-layout.pdf 51-640027-5 5000.0

Open extracts.xlsx and there are four rows under a header row. Three details make the sheet usable:

  • Numbers as numbers. 1,250.50 is turned into 1250.5 before it is written, so the column sorts and adds up. Written as text, it would do neither.
  • A missing value is an empty cell, not a crash. get returns None when a label is not found.
  • The file name is the first column, so you can find the document behind any row.

The fourth file has an extra line and an extra row compared with the others, and the script still reads it, because it looks for labels and not for fixed positions.

What the script cannot do is read a scan, and it needs changing whenever a new kind of document arrives.

Method 3: upload the folder, download the spreadsheet

100sands does the same job in its web app, with no code.

  1. Set up a document type once. Upload one to five sample documents of the kind. AI suggests the fields and each sample's values; you check and correct them, and AI sets up the extraction. It goes live only when it returns every value you checked on every sample.
  2. Open Upload files and choose that document type.
  3. Drop the files or their folder. Before anything runs, you see how many documents your plan has left this month.
  4. Start it. It runs in the background.
  5. Download the results as Excel or CSV.

The spreadsheet has one row per file and one column per field. A value that is not in a file leaves its cell empty, never a guess. A list field becomes one cell with a value on each line, and a table field, such as the lines of an invoice, gets its own sheet in the Excel file. A file that cannot be read, such as a scan, is marked with the reason and not counted.

One upload holds up to 500 files and 500 MB. It reads PDFs and HTML files that contain text, not scans. The Free plan includes 2 document types and 100 documents a month, and a document is one file, whatever its page count.

It reads the named values you set up from each file, one row per file. It does not copy a PDF's tables into cells; for that, use method 1.

Whichever you use, check the result

  • Count the rows. Fifty files in, fifty rows out.
  • Scan for empty cells. An empty cell means a value was not found in that file. Open it and see why.
  • Sort each column. Wrong values tend to gather at the ends: a date in a number column, a name where an amount should be.
  • Spot-check five files against the originals, including the oddest-looking one.

Which to choose

  • The PDFs contain tables you want whole: Excel's From PDF.
  • You want particular values, write Python, and the files are not scans: the script.
  • You want particular values from PDFs with text in them, and no code: an upload. None of the three reads scans; those need OCR first.

Questions

How do I extract data from multiple PDF files into Excel?

Decide which values you want from each file. Then either run a script that reads every PDF in a folder, finds those values and writes one row per file, or use a tool where you upload the folder and download one spreadsheet.

Can Excel import data from a PDF?

Yes. Excel for Microsoft 365 on Windows has Data > Get Data > From File > From PDF, which loads tables found in a PDF. It suits tables, not single values scattered over a page, and it does not read scans.

How do I extract data from a PDF to Excel automatically?

Set up the extraction once for a kind of document, then run it on every new file. In Python that is a script on a schedule. Without code, it is a document type you set up once and uploads you repeat.

Why are my numbers stored as text in Excel?

Values from a PDF are text, such as "1,250.50". Remove the thousands separator and convert to a number before writing the cell, or the column will not sort or add up.

Try it on your own documents

A free plan every month, no credit card. See the PDF data to Excel.

Start free
  • How to extract data from PDF forms

    Read the answers out of fillable PDF forms with pypdf: every field with its type and value, checkboxes, and many forms into one CSV. Plus flat forms.

  • How to extract invoice data in Python

    Pull the number, dates, totals and line items out of a PDF invoice with pypdf and regular expressions, then check that the lines add up. With real output.

  • How to classify documents automatically

    Three ways to sort incoming documents by kind: the labels on the page, a trained model, or a language model. Python code for the first, and how to measure it.