Skip to main content

Geração de relatórios em Python — CSV, XLSX e PDF com performance de Rust.

Project description

pyreps

Geração de relatórios em Python — CSV, XLSX e PDF com performance de Rust.

Python 3.12+ License: MIT

Documentação · PyPI · Issues


✨ Destaques

  • 🚀 Alta Performance — Pipeline 100% streaming. CSV e XLSX usam < 1 MB de RAM com 500K+ linhas.
  • 🦀 Powered by Rust — XLSX via rustpy-xlsxwriter, JSON via orjson.
  • 📄 3 Formatos — CSV, XLSX e PDF com uma única API.
  • 🔌 Plugável — Aceita list[dict], JSON, SQL ou qualquer fonte custom.
  • 🎯 Tipos Declarativos — Coerção automática para int, float, bool, date, datetime.
  • 🪶 Leve — 3 dependências de runtime. Sem pandas, sem numpy.

Instalação

pip install pyreps

Exemplo Rápido

from pyreps import ColumnSpec, ReportSpec, generate_report

data = [
    {"id": 1, "cliente": {"nome": "Ana"}, "total": 100.50},
    {"id": 2, "cliente": {"nome": "Bruno"}, "total": 250.00},
]

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

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

Formatos Suportados

Formato Renderer Motor Streaming
CSV CsvRenderer csv stdlib (C) ✅ Memória constante
XLSX XlsxRenderer rustpy-xlsxwriter (Rust) ✅ Memória constante
PDF PdfRenderer reportlab (C) ⚠️ Materializa (layout)

Fontes de Dados

Fonte Adapter Detecção
list[dict] / generator ListDictAdapter Automática
JSON string / bytes JsonAdapter Automática
dict / Mapping JsonAdapter Automática
SQL query SqlAdapter Explícito
Custom Implemente InputAdapter Explícito

Tipos Declarativos

ColumnSpec(label="Criado", source="created_at", type="date")
ColumnSpec(label="Ativo", source="active", type="bool")    # "sim" → True
ColumnSpec(label="Total", source="total", type="float")     # "3.14" → 3.14

Tipos: str, int, float, bool, date, datetime. Opcional — type=None mantém pass-through.

XLSX — Largura de Colunas

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

SQL

from pyreps import SqlAdapter

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

Performance

Benchmark com 6 colunas e tipos declarativos:

Formato 500K linhas Peak RAM rows/s
CSV 15s 0.16 MB ~33K
XLSX 24s 0.62 MB ~21K

CSV e XLSX mantêm memória constante independente do volume.

Documentação

📖 Documentação completa em pyreps.readthedocs.io

Licença

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.1.5.tar.gz (18.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.1.5-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyreps-0.1.5.tar.gz
  • Upload date:
  • Size: 18.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.1.5.tar.gz
Algorithm Hash digest
SHA256 8beb13bbaf27542c518c4cdee7f4c9b361fcf54915959839fe1c30ff6721dfdc
MD5 7be1967bb62e67e62e0a80150a2bcf72
BLAKE2b-256 97b9060284e1c90ea948409c2f2e094adb1cf51a3dae575631e27a45215cb81f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyreps-0.1.5.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.1.5-py3-none-any.whl.

File metadata

  • Download URL: pyreps-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 24.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.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0ce880170528f8149ff7a26ac43c884172ceb889aca8bb4f862f158ca3c249c5
MD5 504dfe50009375a0b2ae7c167b2b633c
BLAKE2b-256 0816085424649a6de7fca4de3b94cbd31a97b36a5ae9336a770e23769bab9135

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyreps-0.1.5-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