Saltar al contenido
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.py

README.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.

Relacionados

CLI de Python con SQLiteProPlantilla de proyectoUn registro de gastos para el terminal: añade y lista gastos, suma por categoría cada mes y exporta a CSV. Solo usa la biblioteca estándar (argparse, sqlite3), así que no hay nada que instalar con pip, y trae tests con unittest. Necesita Python en el entorno Linux.App web Flask + SQLiteProPlantilla de proyectoUna lista de lectura en Flask con páginas generadas en el servidor y formularios simples, datos en SQLite y una pequeña API JSON. Los tests usan el cliente de pruebas de Flask. Necesita Python y pip en el entorno Linux e instala 7 paquetes con versión fijada.Acortador de enlaces con FastAPIProPlantilla de proyectoUn acortador de enlaces en Python con FastAPI y SQLite. Crea códigos cortos, redirige y cuenta los clics, y trae un formulario de una página y tests con pytest. Necesita Python 3.10 o posterior con pip en el entorno Linux; instala 14 paquetes con versión fijada.Next.js + Tailwind + i18nProPlantilla de proyectoProyecto de Next.js 15 con next-intl y Tailwind CSS, y una página en inglés y español en /en y /es. El modo oscuro sigue al sistema. Necesita el entorno Linux con Node.js; el primer npm install descarga unos 400 MB.Página de aterrizaje estáticaProPlantilla de proyectoUn sitio de una página en HTML y CSS sin más: cabecera con menú plegable, portada, rejilla de funciones, preguntas frecuentes y pie. Los colores siguen el modo claro u oscuro del sistema. No hay que compilar ni hace falta Linux: abre index.html y toca el icono del globo.CLI en Rust: contador de líneasProPlantilla de proyectoUna herramienta de línea de comandos en Rust que cuenta líneas de código, de comentarios y en blanco por lenguaje en una carpeta. Es un proyecto de Cargo sin dependencias y con tests unitarios. Necesita Rust y Cargo en el entorno Linux (unos 370 MB).