Query and render tabular data — in one small object. Zero dependencies.
Most tools make you choose: a query/dataframe library (heavy) or a pretty-printer (no querying). larztable is both, tiny. Load rows, filter/sort/aggregate them with a fluent Django-style API, then print a clean terminal table or export to CSV/Markdown — no pandas, no tabulate.
from larztable import Table
t = Table.from_dicts([
{"name": "Ada", "age": 36, "role": "admin"},
{"name": "Bo", "age": 24, "role": "user"},
{"name": "Cy", "age": 41, "role": "user"},
])
print(t.where(role="user").sort("age", reverse=True).select("name", "age"))┌──────┬─────┐
│ name │ age │
├──────┼─────┤
│ Cy │ 41 │
│ Bo │ 24 │
└──────┴─────┘
- One tool for both jobs. Querying and presenting are the same object:
.where(),.sort(),.select(),.limit(),.group_by(), aggregates — thenprint(t),t.to_csv(),t.to_markdown(). - Expressive filters. Django-style lookups —
where(age__gt=30, role="user", name__icontains="a")— plus arbitrary predicate functions. - Reads like data. Numbers auto-right-align in the Unicode table; CSV round-trips; Markdown for docs and PRs.
- Zero dependencies. No pandas, no tabulate, no numpy.
pip install larztablet.where(role="admin") # equality
t.where(age__gte=30, age__lt=40) # gt/gte/lt/lte/ne/in/contains/...
t.where(lambda r: r["age"] % 2 == 0) # any predicate
t.sort("age", reverse=True)
t.select("name", "age")
t.limit(10, offset=5)
t.distinct("role")
# aggregates
t.count(); t.sum("age"); t.avg("age"); t.min("age"); t.max("age")
t.group_by("role").count() # Table of role, count
t.group_by("role").avg("age") # Table of role, age_avgEvery query returns a new Table (the original is untouched), so chains are safe.
Table.from_csv("data.csv")
Table.from_csv_string("name,age\nAda,36\n")
Table.from_dicts([...])
Table.from_rows([["Ada", 36]], columns=["name", "age"])
t.to_csv("out.csv"); t.to_csv() # string
t.to_markdown()
t.to_dicts(); t.to_rows()
print(t) # pretty terminal tablepython -m unittest discover -s tests -v # 27 tests, zero depsPure-Python, zero-dependency building blocks: larz · larzchain · larzmoney · larzcrypt · larzdb · larzagent · larzchart · larzmark · larztask · larzvault · larzvm · larzcache · larzvalidate · larzid · larzrpc · larzstate · larzhttp · larzconf · larzcron · larzlimit · larzlog · larzcli · larzretry · larztime · larzpdf · larzpack · larztemplate · larzcolor · larztable
MIT © larz-scripter