SKILL.md
PDF Processing Guide
IMPORTANT: Do NOT Use the Read Tool for PDFs
The Read tool cannot properly extract tabular data from PDFs. It will only show you a limited preview of the first page's text content, missing most of the data.
For PDF files, especially multi-page PDFs with tables:
- DO: Use
pdfplumberas shown in this skill - DO NOT: Use the Read tool to view PDF contents
If you need to extract data from a PDF, write Python code using pdfplumber. This is the only reliable way to get complete table data from all pages.
Overview
Extract text and tables from PDF documents using Python libraries.
Table Extraction with pdfplumber
pdfplumber is the recommended library for extracting tables from PDFs.
Basic Table Extraction
import pdfplumber
with pdfplumber.open("document.pdf") as pdf:
for page in pdf.pages:
tables = page.extract_tables()
for table in tables:
print(table) # List of lists
Convert to pandas DataFrame
import pdfplumber
import pandas as pd
with pdfplumber.open("document.pdf") as pdf:
page = pdf.pages[0] # First page
tables = page.extract_tables()
if tables:
# First row is usually headers
table = tables[0]
df = pd.DataFrame(table[1:], columns=table[0])
print(df)
Extract All Tables from Multi-Page PDF
import pdfplumber
import pandas as pd
all_tables = []
with pdfplumber.open("document.pdf") as pdf:
for page in pdf.pages:
tables = page.extract_tables()
for table in tables:
if table and len(table) > 1: # Has data
df = pd.DataFrame(table[1:], columns=table[0])
all_tables.append(df)
# Combine if same structure
if all_tables:
combined = pd.concat(all_tables, ignore_index=True)
