Xlea
Python library that makes it easy to convert Excel tables into ORM-like objects
Install / Use
/learn @artanador/XleaREADME
XLEA
xlea is a python library that makes it easy to convert Excel tables into ORM-like objects.
The library focised on schema-driven parsing of tabular data, where column resolution, validation and type conversion are handled explicitly and predictably.
Features
- Declarative schema definition
Describe tabular data using Python classes with type annotations and column descriptors.
- Automatic column resolution
Columns are matched by name, regular expression, or custom predicate — no hard-coded indexes.
- Type-driven value conversion
Cell values are automatically cast using schema type annotations with explicit error reporting.
- Header-aware parsing
Support for multi-row headers and complex header layouts via schema configuration.
- Pluggable provider architecture
File formats are handled by interchangeable providers, selected automatically by file extension.
- Excel formats out of the box
Native support for .xlsx, .xls, and .xlsb via dedicated providers.
- Row-level validation
Custom validators can be attached to columns to enforce domain-specific constraints.
- Graceful handling of invalid data
Optionally skip rows with invalid values instead of failing the entire read.
Installation
pip install xlea
Example
Defining a Schema
from typing import Optional
from xlea import Schema, Column, config
age_name = lambda name: name.startswith("Age")
age_validator = lambda val: val.isnumeric()
@config(header_rows=2)
class Person(Schema):
id: str = Column("ID")
fullname: str = Column("Profile;Last Name, First Name", ignore_case=True)
age: int = Column(age_name, validator=age_validator, skip_invalid_row=True)
city: Optional[str] = Column("City", required=False, default="Voronezh")
Reading an Excel file
import xlea
from xlea.providers.openpyxl import OpenPyXlProvider
from schemas import Person
def main():
persons = xlea.read(OpenPyXlProvider("test_data.xlsx"), schema=Person)
# or with automatic provider selection
persons = xlea.autoread("test_data.xlsx", schema=Person)
for p in persons:
print(p.id, p.fullname, p.age)
if __name__ == "__main__":
main()
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
