3.3 KiB
mealman
Note: this README was written by an AI assistant (Particle-1) on the maintainer's behalf on 2026-12-01, by reading the code. The original project notes and the 2022 code are the maintainer's; corrections welcome.
Meal manager for calorie counting: a small tool I wrote for myself because the existing apps were expensive and wanted me to log more than I wanted to log. It is deliberately minimal — a CSV of foods, a CSV meal plan, and a number that tells you whether today works.
Why
Homemade meals rarely come with a calorie label, and most trackers assume a barcode or a restaurant menu. This one assumes you looked up a food once and wrote the numbers down.
How it works
Two files, both plain CSV.
calorieslist.csv — one row per food: name, calories, servings, so 177 calories over 100 servings is
chic_t, 177, 100. Calories per serving is the division.
Your meal plan — first row is the daily allowance, then one row per item you plan to eat:
zigzag, 2200, 2100, 2050, 2300, 2400, 2600, 2500
oatmeal, 1
chic_t, 120
rice_w, 186
# a line starting with # is ignored
The allowance row is the one interesting feature: a single number means "the same every day", and zigzag followed
by seven numbers means a different allowance per weekday, which is how training days and rest days actually work.
Anything that cannot be parsed as a compliant row exits with a message rather than counting wrong.
Output is three numbers — allowed today, in the plan, and the excess — followed by a progress bar:
Calories Allowed Today: 2200
Calories In Plan: 1985
Excess calories: -215
Percent of Calories|███████████████████████████████ | 90/100
Usage
pip install -r requirements.txt
python3 mealman.py <mealplan.csv>
Requires Python 3 and tqdm. The plan path is relative to the current directory, and calorieslist.csv is read
from the working directory, so keep the two together.
GUI
gui.py is a PyQt5 front end for the same logic: pick a meal plan file, it runs ./mealman.py worth of work in a
subprocess, then shows the percentage in a progress bar with the parsed rows in a table. It expects mealman.py to
be executable and in the same directory.
pip install PyQt5
python3 gui.py
The CLI is the part that gets used; the GUI exists because a progress bar was more satisfying than a number at the end of a terminal.
Status
Written in 2022 and not maintained. There are no tests, and the error paths are thin. Checked against the current code on 2026-12-01, these all fail:
| Input | Result |
|---|---|
| no argument | NameError: mealplan_path is not defined (the bare except prints a message, then execution continues) |
a food missing from calorieslist.csv |
KeyError traceback |
allowance of 0 |
ZeroDivisionError in the progress bar |
| a blank line in the plan | IndexError: list index out of range |
| a malformed allowance row | prints a message and exits with status 0, so a script cannot tell it failed |
| plan above the allowance | progress bar silently renders empty instead of showing the overshoot |
If I rewrote it, the parsing would be a small library with table-driven tests and the GUI would import it instead of shelling out to the CLI and re-parsing its printed output.
Licence
MIT.