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.
| Method | Good for | Needs |
|---|---|---|
| Excel's own "From PDF" | Tables inside PDFs | Excel for Microsoft 365 on Windows |
| A Python script | Named values, full control | Someone who writes Python |
| Upload to a service | Named values, no code | An 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.
pip install pypdf openpyxlimport 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"])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.0Open extracts.xlsx and there are four rows under a header row. Three details make the sheet usable:
- Numbers as numbers.
1,250.50is 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.
getreturnsNonewhen 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.
- 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.
- Open Upload files and choose that document type.
- Drop the files or their folder. Before anything runs, you see how many documents your plan has left this month.
- Start it. It runs in the background.
- 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.