Plantilla de proyecto·Pro
Informe CSV en Python
Un script que convierte un CSV de ventas en un resumen en el terminal y una página HTML con gráficos de barras: totales por mes, categoría y producto. Solo usa la biblioteca estándar y trae datos de ejemplo y tests. Necesita Python en el entorno Linux.
Para instalarlo necesitas PocketCode Pro.
Si tienes PocketCode instalado en tu Android, esto abre la página en la app.
Vista previa
Ficheros
README.md
data/sales.csv
report.py
tests/__init__.py
tests/test_report.pyREADME.md
# Sales report from a CSV, in Python A script that reads a CSV of sales and gives you two things: a summary in the terminal (revenue, units, median sale, totals per month and per category) and `report.html`, a page with bar charts that works offline. It only uses Python's standard library (csv, decimal, statistics, html): nothing to install with pip. Sample data is included. ## Run it in PocketCode You need the app's Linux environment with Python 3.10 or newer: install it in Settings › Compilers and runtimes, or with the Developer pack in Terminal › Linux. When you tap Run, the first line of the Run panel should say Python 3 (Linux). 1. Open `report.py` and tap Run. The Run panel prints the summary and writes `report.html`. 2. Open `report.html` and tap the globe icon (DevBrowser) at the top of the editor to see the charts. With your own data, from the terminal (Open Terminal Here, in the editor menu): ```sh python3 report.py my-sales.csv -o my-report.html ``` The CSV needs these columns: `date` (YYYY-MM-DD), `product`, `category`, `units`, `unit_price`. A wrong line stops the script and says which line it is. ## Run the tests ```sh python3 -m unittest -v ``` ## Where things are | Path | What it does | |---|---| | `report.py` | Reading the CSV, the totals, the terminal summary and the HTML | | `data/sales.csv` | Sample data: 32 sales over three months | | `tests/test_report.py` | Tests with unittest |Esta vista previa está recortada. El contenido completo llega al instalarlo.
Cambios en la 1.0.0
Primera versión.