← Back to all products
$19
Report Generator
Build formatted reports from CSV, JSON, or SQLite data: filter, group, aggregate, sort, and render to Markdown, HTML, CSV, or JSON with summary stats and ASCII charts.
JSONMarkdownPython
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 11 files
report-generator/
├── LICENSE
├── README.md
├── examples/
│ ├── report_generator_config.json
│ └── sample_data.csv
├── free-sample.zip
├── guide/
│ ├── 01_features.md
│ ├── 02_quick-start.md
│ ├── 03_output.md
│ └── 04_license.md
├── index.html
└── src/
└── report_generator.py
📖 Documentation Preview README excerpt
Report Generator
Build formatted reports from tabular data (CSV, JSON, SQLite). Filter, group, aggregate, sort, and render to Markdown, HTML, CSV, or JSON — all with Python stdlib, no external dependencies. Includes summary statistics and inline ASCII bar charts for group aggregates.
Features
- Multi-source input — CSV files, JSON files (flat or nested), SQLite databases
- Row filtering — Keep rows matching conditions (eq, ne, gt, lt, gte, lte, contains, regex, in, not_null, is_null)
- Computed columns — Add derived fields via arithmetic expressions or string templates
- Group-by aggregation — Group by one or more fields with count, sum, avg, min, max
- Sorting — Sort results by any column, ascending or descending
- Multiple output formats — Markdown tables, self-contained styled HTML, CSV, JSON
- Summary statistics — Automatic count, sum, avg, min, max, stdev for every numeric column
- ASCII bar charts — Inline horizontal bar charts for each aggregate metric
- JSON report definitions — Declare complete reports in a config file for repeatable generation
- Automatic type coercion — CSV string values are converted to int/float when possible
Requirements
- Python 3.10+
- No external dependencies (stdlib only)
Quick Start
# Simple detail report from CSV
python src/report_generator.py --source examples/sample_data.csv --format markdown
# Group by department with aggregated metrics
python src/report_generator.py --source examples/sample_data.csv \
--group-by department \
--metrics "revenue:sum,revenue:avg,deals_closed:sum,satisfaction:avg" \
--sort "revenue_sum:desc" \
--title "Department Summary"
# Full report from a JSON config file
python src/report_generator.py --config examples/report_generator_config.json
# HTML report written to a file
python src/report_generator.py --source examples/sample_data.csv \
--group-by department --metrics "revenue:sum" \
--format html --output department_report.html
# Filter rows before aggregating
python src/report_generator.py --source examples/sample_data.csv \
--filter "region:eq:North" \
--group-by department --metrics "revenue:sum"
Configuration Reference
CLI Options
| Flag | Short | Default | Description |
|---|---|---|---|
--source | -s | — | Source data file (CSV, JSON, or SQLite) |
--format | -f | markdown | Output format: markdown, md, html, csv, json |
--group-by | -g | — | Comma-separated fields to group by |
--metrics | -m | — | Metric specs: field:agg (e.g. revenue:sum,hours:avg) |
--output | -o | stdout | Output file path |
... continues with setup instructions, usage examples, and more.
📄 Code Sample .py preview
src/report_generator.py
#!/usr/bin/env python3
"""
Report Generator — Automation Hub (DataNest)
Build formatted reports from tabular data (CSV, JSON, SQLite). Supports
filtering, group-by with aggregations (count/sum/avg/min/max), sorting,
computed columns, and rendering to Markdown, HTML, CSV, or JSON. Includes
summary statistics and inline ASCII bar charts for group aggregates.
Usage:
python report_generator.py --source data.csv --format markdown
python report_generator.py --source sales.csv --group-by region --metrics "revenue:sum"
python report_generator.py --config examples/report_generator_config.json
python report_generator.py --source data.json --format html --output report.html
Dependencies: Python 3.10+ stdlib only (no pip packages)
License: MIT
"""
from __future__ import annotations
import argparse
import csv
import io
import json
import logging
import re
import sqlite3
import textwrap
import time
from collections import defaultdict
from dataclasses import dataclass, field
from datetime import datetime, timezone
from html import escape as html_escape
from pathlib import Path
from typing import Any
# ---------------------------------------------------------------------------
# Constants
# ---------------------------------------------------------------------------
LOG_FORMAT = "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
CHART_BAR_CHAR = "\u2588" # full-block character: █
CHART_MAX_WIDTH = 36
VERSION = "1.0.0"
logger = logging.getLogger("report_generator")
# ---------------------------------------------------------------------------
# ... 849 more lines ...