Skip to main content

Python report generation — CSV, XLSX, and PDF with Rust performance.

Project description

pyreps

Python report generation — CSV, XLSX, and PDF with Rust performance.

CI codecov Python 3.12+ License: MIT

Documentation · PyPI · Issues


✨ Highlights

  • 🚀 High Performance — 100% streaming pipeline. CSV and XLSX use < 1 MB of RAM with 500K+ rows.
  • 🦀 Powered by Rust — XLSX via rustpy-xlsxwriter, JSON via orjson.
  • 📄 3 Formats — CSV, XLSX, and PDF with a single API.
  • 🔌 Pluggable — Supports list[dict], JSON, SQL, or any custom source.
  • 🎯 Declarative Types — Automatic coercion for int, float, bool, date, datetime.
  • 🪶 Lightweight — 3 runtime dependencies. No pandas, no numpy.

Installation

pip install pyreps

Quickstart

from pyreps import ColumnSpec, ReportSpec, generate_report

# data sample
data = [
    {"id": 1, "customer": {"name": "Ana"}, "total": 100.50},
    {"id": 2, "customer": {"name": "Bruno"}, "total": 250.00},
]

spec = ReportSpec(
    output_format="csv",  # or "xlsx" or "pdf"
    columns=[
        ColumnSpec(label="ID", source="id", type="int", required=True),
        ColumnSpec(label="Customer", source="customer.name"),
        ColumnSpec(label="Total", source="total", type="float",
                   formatter=lambda v: f"$ {v:.2f}"),
    ],
)

path = generate_report(data_source=data, spec=spec, destination="sales.csv")

Supported Formats

Format Renderer Engine Streaming
CSV CsvRenderer csv stdlib (C) ✅ Constant memory
XLSX XlsxRenderer rustpy-xlsxwriter (Rust) ✅ Constant memory
PDF PdfRenderer reportlab (C) ⚠️ Materializes (layout)

Data Sources

Source Adapter Detection
list[dict] / generator ListDictAdapter Automatic
JSON string / bytes JsonAdapter Automatic
dict / Mapping JsonAdapter Automatic
SQL query SqlAdapter Explicit
Custom Implement InputAdapter Explicit

Declarative Types

ColumnSpec(label="Created", source="created_at", type="date")
ColumnSpec(label="Active", source="active", type="bool")    # "yes" → True
ColumnSpec(label="Total", source="total", type="float")     # "3.14" → 3.14

Types: str, int, float, bool, date, datetime. Optional — type=None maintains pass-through.

XLSX — Column Widths

spec = ReportSpec(
    output_format="xlsx",
    columns=[...],
    metadata={
        "xlsx": {
            "width_mode": "auto",     # "manual" | "auto" | "mixed"
            "sheet_name": "Sales",
            "columns": {
                "ID": {"width": 8.0},
                "Description": {"min_width": 20.0, "max_width": 50.0},
            },
        }
    },
)

SQL

from pyreps import SqlAdapter

generate_report(
    data_source=None,
    spec=spec,
    destination="sales.csv",
    input_adapter=SqlAdapter(
        query="SELECT id, name, total FROM sales",
        connection=connection,
    ),
)

Performance

Benchmark with 6 columns and declarative types:

Format 500K rows Peak RAM rows/s
CSV 2.39s 51.11 MB ~209K
XLSX 4.37s 51.11 MB ~114K

Memory usage remains stable (approx. 51MB process baseline) regardless of volume due to the 100% streaming pipeline.

Documentation

📖 Complete documentation at JhonatanRian.github.io/pyreps

License

MIT

Project details


Download files

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

Source Distribution

pyreps-0.2.0.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

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

pyreps-0.2.0-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file pyreps-0.2.0.tar.gz.

File metadata

  • Download URL: pyreps-0.2.0.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyreps-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8a9dea3a2d5d929ad3a8c153a1eaa5ece2a4d35f4bb7f6f13feaf1b19b6e1c2b
MD5 04491ecacd6408a17b4aa06bf497e351
BLAKE2b-256 a665d5d6f7cc8bbc25af3548c159595145d4f5987b4d874a23bf5c2f2aca9107

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyreps-0.2.0.tar.gz:

Publisher: publish.yml on JhonatanRian/pyreps

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyreps-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pyreps-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 29.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyreps-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec632f66917feacaae5c488a38d2f8aea4e32ad19e72c9c5d9d598af8019fb74
MD5 5362a632f2ec8013ef91ca518e8db17c
BLAKE2b-256 b75627905957a9bde5e4e1da4f8525be56f81275bcc77c012791f5e734181b2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyreps-0.2.0-py3-none-any.whl:

Publisher: publish.yml on JhonatanRian/pyreps

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page