Extract structured data from Excel files using YAML schema definitions
Project description
stencilpy
Extract structured data from Excel files using YAML schema definitions into dynamically-generated Pydantic models.
Installation
pip install stencilpy
The stencil open command serves the bundled editor UI locally and opens it in your browser.
Quick Start
from stencilpy import Stencil
# Load a schema
lab = Stencil("lab_report.stencil.yaml")
# Extract data — version auto-detected via discriminator
report = lab.extract("january_lab.xlsx")
print(report.patient_name)
print(report.model_dump())
Schema Format
Create a .stencil.yaml file:
name: lab_report
description: Monthly lab report
discriminator:
cells:
- A1
versions:
"v2.0":
fields:
patient_name:
cell: B3
sample_date:
cell: B4
type: datetime
readings:
range: D5:D
type: list[float]
report_version:
cell: header:right
footer_note:
cell: footer:center
Scalar cell references can also target worksheet headers and footers:
header:leftheader:centerheader:rightfooter:leftfooter:centerfooter:rightSheet1!header:first:rightSheet1!footer:even:center
These references also work in discriminator.cells, which is useful when a workbook version is printed in the page header/footer instead of a normal cell.
Header And Footer References
Use header/footer refs anywhere a scalar cell ref is accepted.
Example: extract version text and report metadata from the page chrome.
name: lab_report
description: Monthly lab report
discriminator:
cells:
- A1
versions:
"v2.0":
fields:
patient_name:
cell: B3
report_version:
cell: header:right
report_title:
cell: header:center
generated_by:
cell: footer:left
footer_note:
cell: footer:center
If the workbook uses separate first-page or even-page headers/footers, include the page selector:
versions:
"v2.0":
fields:
first_page_title:
cell: header:first:center
even_page_version:
cell: footer:even:right
cover_sheet_version:
cell: Cover!header:first:right
Supported formats:
header:leftheader:centerheader:rightheader:first:leftheader:even:centerfooter:rightfooter:first:centerSheet1!header:rightSheet1!footer:even:left
Header-Based Version Detection
If a workbook stores its version in a header or footer instead of a normal cell, add those refs to discriminator.cells.
name: lab_report
description: Monthly lab report
discriminator:
cells:
- A1
- header:right
- Cover!footer:first:center
versions:
"v1.0":
fields:
patient_name:
cell: A3
"v2.0":
fields:
patient_name:
cell: B3
stencilpy will check each discriminator ref in order until one matches a known version key.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stencilpy-0.5.6.tar.gz.
File metadata
- Download URL: stencilpy-0.5.6.tar.gz
- Upload date:
- Size: 27.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc0ecbc561c43843d4496ad4033ce9e693964fbee041639dd84ebbf37825e2dc
|
|
| MD5 |
a7e4ed1a3fd76abdae41b98733809a3d
|
|
| BLAKE2b-256 |
beafaaf6eb481c8a24536af4eadae79c2262a5753e0359761ff1c651db94375a
|
Provenance
The following attestation bundles were made for stencilpy-0.5.6.tar.gz:
Publisher:
publish.yml on phlohouse/stencil
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stencilpy-0.5.6.tar.gz -
Subject digest:
cc0ecbc561c43843d4496ad4033ce9e693964fbee041639dd84ebbf37825e2dc - Sigstore transparency entry: 1186330006
- Sigstore integration time:
-
Permalink:
phlohouse/stencil@f20ea144c63b9be8682d231c45ec736a8fc270fb -
Branch / Tag:
refs/tags/v0.5.6 - Owner: https://github.com/phlohouse
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f20ea144c63b9be8682d231c45ec736a8fc270fb -
Trigger Event:
push
-
Statement type:
File details
Details for the file stencilpy-0.5.6-py3-none-any.whl.
File metadata
- Download URL: stencilpy-0.5.6-py3-none-any.whl
- Upload date:
- Size: 23.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cba9d32da68c2300399c0238007bb462395ea9e00161ec0a3862d895bc38e9bb
|
|
| MD5 |
5c6d108ecc38392c369017916f14864a
|
|
| BLAKE2b-256 |
a27af815c7ff25f4abbefef4f4fbdbe44dbba2120c0b086728f01c72570cf95d
|
Provenance
The following attestation bundles were made for stencilpy-0.5.6-py3-none-any.whl:
Publisher:
publish.yml on phlohouse/stencil
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stencilpy-0.5.6-py3-none-any.whl -
Subject digest:
cba9d32da68c2300399c0238007bb462395ea9e00161ec0a3862d895bc38e9bb - Sigstore transparency entry: 1186330015
- Sigstore integration time:
-
Permalink:
phlohouse/stencil@f20ea144c63b9be8682d231c45ec736a8fc270fb -
Branch / Tag:
refs/tags/v0.5.6 - Owner: https://github.com/phlohouse
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f20ea144c63b9be8682d231c45ec736a8fc270fb -
Trigger Event:
push
-
Statement type: