Skip to content
Project template·Pro

Python CSV report

A script that turns a CSV of sales into a summary in the terminal and an HTML page with bar charts of totals per month, category and product. It only uses the standard library and includes sample data and tests. It needs Python in the Linux environment.

You need PocketCode Pro to install it.

If PocketCode is installed on your Android device, this opens the page in the app.

Preview

Files

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 |

This preview is shortened. You get the full content when you install it.

Changes in 1.0.0

First version.

Related

Python CLI with SQLiteProProject templateAn expense tracker for the terminal. It adds and lists expenses, totals them per category each month and exports CSV. It only uses the standard library (argparse, sqlite3), so there's nothing to pip install, and it has unittest tests. It needs Python in the Linux environment.Flask + SQLite web appProProject templateA reading list in Flask with server-rendered pages and plain forms, SQLite storage and a small JSON API. The tests use Flask's test client. It needs Python and pip in the Linux environment and installs 7 pinned packages.FastAPI link shortenerProProject templateA link shortener in Python with FastAPI and SQLite: it creates short codes, redirects and counts clicks. It comes with a one-page form and pytest tests. It needs Python 3.10 or newer with pip in the Linux environment and installs 14 pinned packages.Next.js + Tailwind + i18nProProject templateNext.js 15 project with next-intl and Tailwind CSS, and one page in English and Spanish at /en and /es. Dark mode follows the system. Needs the Linux environment with Node.js; the first npm install downloads around 400 MB.Static landing pageProProject templateA one-page site in plain HTML and CSS with a header and folding menu, a hero, a feature grid, an FAQ and a footer. Colours follow the system's light or dark setting. There is no build step and it doesn't need Linux: open index.html and tap the globe icon.Rust CLI: line counterProProject templateA command-line tool in Rust that counts code, comment and blank lines per language in a folder. It's a Cargo project with no dependencies and has unit tests. It needs Rust and Cargo in the Linux environment (about 370 MB).