Skip to main content

larztable

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 │
└──────┴─────┘

Why

  • One tool for both jobs. Querying and presenting are the same object: .where(), .sort(), .select(), .limit(), .group_by(), aggregates — then print(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.

Install

pip install larztable

Query

t.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_avg

Every query returns a new Table (the original is untouched), so chains are safe.

Load & export

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 table

Tests

python -m unittest discover -s tests -v   # 27 tests, zero deps

The Larz stack

Pure-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

License

MIT © larz-scripter

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

larztable-0.1.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

larztable-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file larztable-0.1.0.tar.gz.

File metadata

  • Download URL: larztable-0.1.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for larztable-0.1.0.tar.gz
Algorithm Hash digest
SHA256 231d25390dec26b3b5bc917f15d05189b62f78bfe1fc7bc80cb43b366faaa0f8
MD5 2342ed41e92bdcd6d4db99600bb080c3
BLAKE2b-256 3f041afcc90e20335408af2e179ca398a96e20bdd9e50a35a3ad0b1dada9ed18

See more details on using hashes here.

File details

Details for the file larztable-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: larztable-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for larztable-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73a74b7ce655bf2f8533c93f12d119804baedaf36bbd32983cb14942f881c6fd
MD5 b47c34f538066f1c9e04b71c97075170
BLAKE2b-256 4a69b1927be8046dc366ca21f71814b6696a05a16d0ab1544632a550ecf8a248

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page