Column¶
Matching strategies at a glance¶
Pattern type |
Behaviour |
|---|---|
|
Exact match (or case-insensitive with |
|
Compiled to |
Matched with |
|
|
Called with each header cell; first |
Examples¶
import re
from xlea import Schema, Column
class Invoice(Schema):
# Exact match
invoice_id: int = Column("Invoice ID")
# Case-insensitive
client: str = Column("client name", ignore_case=True)
# Regex from string
ref: str = Column(r"^Ref\s*#?\s*\d*$", regexp=True)
# Compiled regex
amount: float = Column(re.compile(r"amount", re.IGNORECASE))
# Callable predicate
note: str = Column(
lambda h: h.lower().startswith("note"),
required=False,
default="",
)