periodic-report-kit
The monthly report someone used to assemble by hand over hours, generated in seconds from the data, with consistent figures and without erasing the comment a person already wrote.
AI-powered softwareAI and data sciencePublic-sector data
Repository ↗PyPI: periodic-report-kit ↗
⬇ Semester report, Word (0.8 MB)⬇ Semester report, PDF (0.9 MB)⬇ Monthly report, Word (0.8 MB)
- ~11 sto generate six months of data and two reports with PDF
- 14domain rules, each with a test
- 75tests
- 0discrepancies when checking the report against its own model
- 3output formats: Word, PDF and PowerPoint
- MITlicence · PyPI 0.1.1
Sample reports generated with the package
Generated with «reportkit demo» (0.1.1, freshly installed from PyPI) from six months of synthetic data that includes the real-world traps each rule exists for: drafts, lock files, blank results, duplicate controls, a sheet that lies about its size and a UTC export. The «Nordal Analytics» brand is fictitious and the reports are in Spanish. The final annex lists the loading warnings: what was set aside and why.
The problem
In many recurring inspection or control services, the periodic report is assembled by hand: someone exports spreadsheets from the field system, recalculates totals in pivot tables, pastes figures and charts into a letterhead Word document and redoes the cover every month. It takes hours, the summary figures end up contradicting the chapters, and regenerating the document erases the comments someone had already written.
How I solved it
- Loaders that translate rather than interpret: they accept whatever the field system exports (inconsistent names, hand-made summary sheets, drafts) and send anything unknown to quarantine with a typed warning.
- A canonical model as the boundary: one row per evaluated item. Above it nothing knows which file the data came from, so switching the source to an API only touches the loader.
- Named metrics with a declared base: two easily confused rates have fixed names, volume is summed and rates only compare like with like. Whatever cannot be computed is
[[PENDIENTE]](pending), never zero. - Rules in configuration: the data schema, groups, items and the catalogue of sections and charts are YAML with tests. A changing criterion is one line, not a deployment.
- The human comment survives: it is stored in YAML per period; if its figures no longer match the current ones, the report flags it. It is never written automatically.
- Branded output: Word with a real table of contents that Word updates and a cover made of text over an anchored background; PDF rendered in two passes joined with pypdf so the cover stays outside the page numbering; Markdown to Word or PowerPoint with nine visual blocks.
- Validator: checks the report against what was delivered and exits with an error on any discrepancy. Each run writes to a new versioned folder: a deliverable is never overwritten.
A clean-room case study
The patterns come from my work at Intervalor Data and are published with the company’s permission. It was rebuilt from a written specification, with synthetic data and a fictitious brand generated by script; the independent review against the original repositories found no copied fragments.
Technologies
- Python 3.11+
- pandas
- matplotlib
- python-docx
- python-pptx
- xhtml2pdf
- pypdf
- Pillow
- PyYAML
- typer
- pytest
- ruff
- GitHub Actions
- gitleaks




