| name | datasheet-extraction |
| description | Extract data from electronics/component datasheets (PDF). Use when processing datasheets for pin tables, electrical characteristics, timing specs, absolute maximum ratings, or ordering information. Combine with pdf-extraction skill. |
Datasheet Extraction
Extract structured data from electronics and component datasheets for software implementation — register maps, pin assignments, electrical characteristics, timing parameters.
When to Use
- Extracting pin tables, register maps, or electrical specs from component datasheets
- Pulling absolute maximum ratings, DC/AC characteristics, timing diagrams
- Getting ordering information or part number variants
- Building drivers, HALs, or configuration code from datasheet parameters
Prerequisite: Load the pdf-extraction skill for the underlying PDF tools and scripts.
Extraction Strategy
Datasheets are table-heavy. Default to pdfplumber with "lines" strategy since most datasheet tables have explicit borders.
Quick Start
import pdfplumber
import pandas as pd
with pdfplumber.open("datasheet.pdf") as pdf:
for page in pdf.pages:
tables = page.extract_tables({
"vertical_strategy": "lines",
"horizontal_strategy": "lines",
"snap_tolerance": 5,
})
for table in tables:
if table and len(table) > 1:
df = pd.DataFrame(table[1:], columns=table[0])
print(df)
Common Patterns
Electrical Characteristics Table
def extract_specs_table(pdf_path, page_num=None):
"""Extract specification tables from component datasheets."""
import pdfplumber
import pandas as pd
dfs = []
with pdfplumber.open(pdf_path) as pdf:
pages = [pdf.pages[page_num]] if page_num is not None else pdf.pages
for page in pages:
tables = page.extract_tables({
"vertical_strategy": "lines",
"horizontal_strategy": "lines",
"snap_tolerance": 5,
})
for table in tables:
if table and len(table) > 1:
df = pd.DataFrame(table[1:], columns=table[0])
dfs.append(df)
return dfs
Pin Assignment Table
def extract_pin_table(pdf_path):
"""Extract pin assignment/function table."""
import pdfplumber
with pdfplumber.open(pdf_path) as pdf:
for page in pdf.pages:
text = page.extract_text() or ""
if any(kw in text.lower() for kw in ["pin name", "pin description", "pin assignment", "pin function"]):
tables = page.extract_tables({
"vertical_strategy": "lines",
"horizontal_strategy": "lines",
})
for table in tables:
header = [str(c).lower() for c in (table[0] or [])]
if any("pin" in h for h in header):
return table
return None
Register Map
def extract_register_map(pdf_path):
"""Extract register definitions from a datasheet."""
import pdfplumber
registers = []
with pdfplumber.open(pdf_path) as pdf:
for page in pdf.pages:
tables = page.extract_tables({
"vertical_strategy": "lines",
"horizontal_strategy": "lines",
})
for table in tables:
if not table or len(table) < 2:
continue
header = [str(c).strip().lower() for c in (table[0] or [])]
if any(kw in " ".join(header) for kw in ["address", "register", "offset", "bit"]):
for row in table[1:]:
registers.append(dict(zip(table[0], row)))
return registers
Table Troubleshooting
Inconsistent Borders
Some datasheets have partial or missing table borders. Switch from "lines" to "text" strategy:
table_settings = {
"vertical_strategy": "text",
"horizontal_strategy": "text",
"snap_tolerance": 3,
"join_tolerance": 3,
"min_words_vertical": 3,
"min_words_horizontal": 1,
"intersection_tolerance": 3,
}
tables = page.extract_tables(table_settings)
Visual Debugging
When tables aren't detected correctly, visualize what pdfplumber sees:
im = page.to_image(resolution=150)
im.debug_tablefinder()
im.save("debug.png")
Multi-Page Tables
Electrical specs often span multiple pages. Extract all, then concatenate by matching column headers:
def extract_multipage_table(pdf_path, header_keywords):
"""Concatenate tables spanning multiple pages."""
import pdfplumber
import pandas as pd
all_rows = []
header = None
with pdfplumber.open(pdf_path) as pdf:
for page in pdf.pages:
for table in page.extract_tables():
if not table or len(table) < 2:
continue
row0 = [str(c).lower() for c in (table[0] or [])]
if any(kw in " ".join(row0) for kw in header_keywords):
header = table[0]
all_rows.extend(table[1:])
elif header and len(table[0]) == len(header):
for row in table:
if row != header:
all_rows.append(row)
if header and all_rows:
return pd.DataFrame(all_rows, columns=header)
return None
Tips
- Pin tables usually have bordered cells → use
"lines" strategy
- Electrical specs may span multiple pages — extract all, then filter by column headers
- If tables are missed, try
"text" strategy instead of "lines"
- Part numbers / ordering info are usually in the first or last pages
- Header block (part number, description, features) is typically in a fixed region on page 1 — use
page.crop() to isolate it
- Footnotes under tables (conditions, test circuits) are important for correctness — extract surrounding text too