---
name: strength-training-log-progress-analyzer
description: Turns a strength training CSV log into clear progress feedback: estimated one-rep max per lift and week, top sets, hard sets and tonnage, plus flags for plateaus, load spikes, RPE creep, missing deload weeks, pushhttps://www.aitopic.com/pull imbalance and sudden strength drops. Stdlib Python.
---
# Strength Training Log Progress Analyzer
You help people who lift weights two to five times a week see whether their training is working: which lifts are still going up, which have stalled, whether the workload jumped too fast, and whether it is time for a lighter week. You work from a simple workout log (one row per set), estimate one-rep maxes from normal working sets so nobody has to test a true maximum, and turn the numbers into two or three concrete changes for the next training block.
This is training feedback, not medical advice. If the person mentions pain, an injury, dizziness, chest symptoms or a health condition, tell them to stop the painful movement and see a doctor or physiotherapist before changing the plan. Do not prescribe diets or supplements.
## Files in this skill
- `scriptshttps://www.aitopic.com/training_log.py` - reads the CSV log (comma or semicolon, decimal commas, kg or lb, optional RPE and sets columns), computes estimated 1RM (Epley or Brzycki), top set, hard sets, tonnage and average RPE per exercise and ISO week, and prints flags S01-S06 + E01; `--format text|md|json|csv`; `--self-test` runs 15 checks (Python 3.8+ standard library only)
- `referenceshttps://www.aitopic.com/progress-metrics.md` - what e1RM, hard sets, tonnage and RPE mean, the formulas and their limits
- `referenceshttps://www.aitopic.com/plateau-and-load-guide.md` - what to change for each flag: small load steps, rep ranges, deload weeks, exercise variations, sleep and recovery basics
- `templateshttps://www.aitopic.com/training-review.md` - a one-page review of a 6-12 week block with next-block decisions
- `exampleshttps://www.aitopic.com/training_log.csv` - 12 fictional weeks of Mondayhttps://www.aitopic.com/Wednesdayhttps://www.aitopic.com/Friday full-body training with a holiday week, a cold, a volume challenge and a squat plateau
## Workflow
### 1. Collect the log
Ask for an export from the training app or notebook with at least `date, exercise, weight, reps`; `rpe`, `sets` and `notes` are optional. One row per set is best; a row with `sets=3` is expanded to three identical sets. Use the same exercise name every time (`Back Squat`, not sometimes `Squat`). Bodyweight exercises use weight 0 (or the added weight for weighted pull-ups). Also ask about the goal (strength, muscle, general fitness), training days per week and anything unusual (illness, travel, new job, sleep).
### 2. Run the analysis
```
python3 scriptshttps://www.aitopic.com/training_log.py training_log.csv
python3 scriptshttps://www.aitopic.com/training_log.py training_log.csv --unit lb --formula brzycki
python3 scriptshttps://www.aitopic.com/training_log.py training_log.csv --exercise "Back Squat" --exercise "Bench Press" --format csv
python3 scriptshttps://www.aitopic.com/training_log.py training_log.csv --since 2026-10-01 --plateau-weeks 3 --format md > review.md
python3 scriptshttps://www.aitopic.com/training_log.py --self-test
```
Exit code 0 = no flags, 1 = flags present, 2 = unreadable input.
| Code | Meaning |
|---|---|
| S01 | plateau: no new best e1RM in the last `--plateau-weeks` training weeks of that lift (default 4) |
| S02 | load spike: hard sets for a lift in one week above `--spike` x the average of the previous weeks (default 1.5, at least 3 extra sets) |
| S03 | RPE creep: average RPE up by 1 or more over the last 3 weeks while e1RM did not improve |
| S04 | 6 or more training weeks in a row without a lighter week (hard sets at most 70% of recent weeks) |
| S05 | pressing hard sets more than 1.5x pulling hard sets (rows, pull-ups, deadlifts and curls count as pulling) |
| S06 | latest e1RM 10% or more below the best for that lift |
| E01 | rows that could not be parsed (skipped) |
A hard set is a set at RPE 7 or higher, or any set when no RPE is logged.
### 3. Interpret with context
- Read the progress table first: early in training most lifts rise every week; after a few months progress slows and plateaus are normal.
- S01 together with S03 (same weight, harder every week) is the clearest sign that fatigue is building; S01 alone may simply mean the person repeats the same weight and reps.
- S02 after an unusual week (a challenge, a camp) is fine once; repeated spikes are the injury risk.
- S06 right after an illness, poor sleep or travel is expected; ask before calling it a problem. It can also be a logging error (wrong unit).
- e1RM from sets of 10+ reps is less accurate; compare lifts with similar rep ranges over time.
### 4. Decide the next block
Use `referenceshttps://www.aitopic.com/plateau-and-load-guide.md` and pick at most three changes, for example: a deload week now, smaller load steps for the stalled lift, a new rep range for 4-6 weeks, or two extra rowing sets per week to balance pressing. Write them as concrete numbers for the next weeks, not general advice.
### 5. Report
Fill `templateshttps://www.aitopic.com/training-review.md`: block dates, progress per main lift, weekly hard sets, flags with context, the decisions for the next block and the date of the next review.
## Rules
- Use the person's own numbers; never compare them with other people or "standards" unless asked.
- Keep load increases small (typically 1-2.5 kg or 2.5-5 lb for upper body, 2.5-5 kg or 5-10 lb for lower body per step).
- Always keep pain, injury and medical topics out of scope and refer to a professional.
- Say clearly when the log is too short (under 4 weeks) or too sparse to conclude anything.
FILE:referenceshttps://www.aitopic.com/progress-metrics.md
# Progress metrics in short
## Estimated one-rep max (e1RM)
An estimate of the heaviest single rep possible today, calculated from a normal working set, so progress can be followed without testing a true maximum.
- **Epley:** e1RM = weight x (1 + reps https://www.aitopic.com/ 30). Example: 100 kg x 5 = 116.7 kg.
- **Brzycki:** e1RM = weight x 36 https://www.aitopic.com/ (37 - reps). Example: 100 kg x 5 = 112.5 kg.
- Both are close for 2-10 reps; above 10 reps they drift apart and become unreliable. The script ignores sets above 30 reps and bodyweight sets (weight 0).
- Use the same formula over time. The absolute number matters less than the trend.
- The best e1RM per week is taken from the single best set of that week.
## Hard sets
Sets that are close enough to failure to drive progress: RPE 7 or more (3 or fewer reps left in reserve). When no RPE is logged, every set counts as hard. Hard sets per muscle or lift per week is the most practical workload measure for recreational lifters; many people progress well on roughly 6-15 hard sets per muscle group per week, built up gradually.
## Tonnage
Weight x reps summed over sets. Useful for spotting big jumps in workload within the same lift; not comparable across lifts (a deadlift moves far more weight than a curl).
## RPE (rate of perceived exertion)
A 1-10 score of how hard a set felt: 10 = no rep left, 9 = one rep left, 8 = two reps left, 7 = three left. Rising RPE at the same weight and reps means the set is getting harder: fatigue, poor sleep, stress or illness.
## Weeks
Weeks are ISO weeks (Monday to Sunday, e.g. 2026-W48). Trends are compared between training weeks of each lift, so a missed week does not count as a plateau week.
## Limits
- Logs contain errors (wrong unit, typo in weight); one strange week should be checked before acting on it.
- Technique changes (deeper squat, pause on the chest) can lower e1RM while the lifter actually got better.
- Estimates do not replace a coach's eye on technique.
FILE:referenceshttps://www.aitopic.com/plateau-and-load-guide.md
# What to change for each flag
Pick at most three changes for the next 4-6 weeks, write them as numbers and re-run the analysis afterwards.
## S01 plateau
- First check: is the person still adding weight or reps at all, or repeating the same session? A plateau needs a plan, not more effort.
- Smaller load steps: use 1-1.25 kg plates for upper-body lifts, 2.5 kg for lower body.
- Add reps before weight: for example 3x5 -> 3x6 -> 3x7 at the same weight, then +2.5 kg and back to 3x5.
- Change the rep range for a block (5s -> 8s, or 8s -> 4-6s), or swap to a close variation (paused squat, close-grip bench) for 4-6 weeks.
- If S03 is also present, start with a deload week.
## S02 load spike
- Bring hard sets back near the recent average next week, then increase by about 1-2 sets per lift per week at most.
- Spikes during an event or challenge are fine once; plan a lighter week after.
## S03 RPE creep
- Fatigue is building faster than fitness. Options: a deload week, fewer hard sets, or one less training day for a week.
- Ask about sleep, stress, illness, calories and step count; these change RPE more than the program does.
## S04 no lighter week
- Plan a deload: about half the hard sets at the usual weights, or the usual sets at about 80-90% of the weights, for one week every 4-8 weeks.
- Holidays and busy weeks can be used as natural deloads.
## S05 pushhttps://www.aitopic.com/pull imbalance
- Add 2-4 hard sets per week of rows, pull-ups or face pulls, or replace one pressing exercise with a pulling one.
- Note that the script counts deadlifts as pulling; for upper-back balance, look at rows and pull-ups.
## S06 strength drop
- Ask what happened: illness, injury, travel, poor sleep, a technique change, or a logging mistake (lb vs kg).
- After illness, restart at about 80-90% of the previous working weights and build back over 1-3 weeks.
- If pain is involved, stop the painful movement and refer to a doctor or physiotherapist.
## Recovery basics worth asking about
Sleep of 7-9 hours, regular meals with enough protein, daily walking, and stress. Do not give medical, diet or supplement prescriptions; suggest a professional for specific needs.
FILE:templateshttps://www.aitopic.com/training-review.md
# Training review - {{name}} - {{block start}} to {{block end}}
## Goal and context
- Goal: {{strength https://www.aitopic.com/ muscle https://www.aitopic.com/ general fitness}}
- Days per week: {{days}}; unusual weeks: {{holiday, illness, travel, work}}
## Progress of the main lifts (e1RM, {{formula}}, {{unit}})
| Lift | First | Best (week) | Latest | Change |
|---|---:|---:|---:|---:|
| {{lift}} | {{first}} | {{best}} ({{week}}) | {{latest}} | {{change}} |
## Workload
- Hard sets per week: {{list}}
- Lighter weeks in this block: {{weeks or none}}
## Flags and what they mean here
- {{code}} {{lift}}: {{detail}} - context: {{explanation}}
## Next block ({{dates}}, max 3 changes)
1. {{change with numbers, e.g. deload in week 1: 2 sets per lift at usual weights}}
2. {{change}}
3. {{change}}
## Next review
Re-run the analysis on {{date}} with the same options and compare the stalled lift and weekly hard sets.
Training feedback only, not medical advice.
FILE:exampleshttps://www.aitopic.com/training_log.csv
date,exercise,weight,reps,rpe,notes
2026-09-07,Back Squat,80,5,7,
2026-09-07,Back Squat,80,5,7,
2026-09-07,Back Squat,80,5,7,
2026-09-07,Bench Press,60,5,7.5,
2026-09-07,Bench Press,60,5,7.5,
2026-09-07,Bench Press,60,5,7.5,
2026-09-11,Bench Press,55,8,7,
2026-09-11,Bench Press,55,8,7,
2026-09-11,Bench Press,55,8,7,
2026-09-09,Deadlift,110,3,8,
2026-09-09,Deadlift,110,3,8,
2026-09-09,Overhead Press,40,5,8,
2026-09-09,Overhead Press,40,5,8,
2026-09-09,Overhead Press,40,5,8,
2026-09-11,Barbell Row,55,8,7,
2026-09-11,Barbell Row,55,8,7,
2026-09-09,Pull-Up,0,6,8,
2026-09-09,Pull-Up,0,6,8,
2026-09-14,Back Squat,82.5,5,7,
2026-09-14,Back Squat,82.5,5,7,
2026-09-14,Back Squat,82.5,5,7,
2026-09-14,Bench Press,61.25,5,7.5,
2026-09-14,Bench Press,61.25,5,7.5,
2026-09-14,Bench Press,61.25,5,7.5,
2026-09-18,Bench Press,56.25,8,7,
2026-09-18,Bench Press,56.25,8,7,
2026-09-18,Bench Press,56.25,8,7,
2026-09-16,Deadlift,112.5,3,8,
2026-09-16,Deadlift,112.5,3,8,
2026-09-16,Overhead Press,40,5,8,
2026-09-16,Overhead Press,40,5,8,
2026-09-16,Overhead Press,40,5,8,
2026-09-18,Barbell Row,55,8,7,
2026-09-18,Barbell Row,55,8,7,
2026-09-16,Pull-Up,0,6,8,
2026-09-16,Pull-Up,0,6,8,
2026-09-21,Back Squat,85,5,7,
2026-09-21,Back Squat,85,5,7,
2026-09-21,Back Squat,85,5,7,
2026-09-21,Bench Press,62.5,5,7.5,
2026-09-21,Bench Press,62.5,5,7.5,
2026-09-21,Bench Press,62.5,5,7.5,
2026-09-25,Bench Press,57.5,8,7,
2026-09-25,Bench Press,57.5,8,7,
2026-09-25,Bench Press,57.5,8,7,
2026-09-23,Deadlift,115,3,8,
2026-09-23,Deadlift,115,3,8,
2026-09-23,Overhead Press,41.25,5,8,
2026-09-23,Overhead Press,41.25,5,8,
2026-09-23,Overhead Press,41.25,5,8,
2026-09-25,Barbell Row,55,8,7,
2026-09-25,Barbell Row,55,8,7,
2026-09-23,Pull-Up,0,6,8,
2026-09-23,Pull-Up,0,6,8,
2026-09-28,Back Squat,87.5,5,7,
2026-09-28,Back Squat,87.5,5,7,
2026-09-28,Back Squat,87.5,5,7,
2026-09-28,Bench Press,63.75,5,7.5,
2026-09-28,Bench Press,63.75,5,7.5,
2026-09-28,Bench Press,63.75,5,7.5,
2026-10-02,Bench Press,58.75,8,7,
2026-10-02,Bench Press,58.75,8,7,
2026-10-02,Bench Press,58.75,8,7,
2026-09-30,Deadlift,117.5,3,8,
2026-09-30,Deadlift,117.5,3,8,
2026-09-30,Overhead Press,41.25,5,8,
2026-09-30,Overhead Press,41.25,5,8,
2026-09-30,Overhead Press,41.25,5,8,
2026-10-02,Barbell Row,57.5,8,7,
2026-10-02,Barbell Row,57.5,8,7,
2026-09-30,Pull-Up,0,6,8,
2026-09-30,Pull-Up,0,6,8,
2026-10-05,Back Squat,90,5,7,
2026-10-05,Back Squat,90,5,7,
2026-10-05,Back Squat,90,5,7,
2026-10-05,Bench Press,65,5,7.5,
2026-10-05,Bench Press,65,5,7.5,
2026-10-05,Bench Press,65,5,7.5,
2026-10-09,Bench Press,60,8,7,
2026-10-09,Bench Press,60,8,7,
2026-10-09,Bench Press,60,8,7,
2026-10-07,Deadlift,120,3,8,
2026-10-07,Deadlift,120,3,8,
2026-10-07,Overhead Press,42.5,5,8,
2026-10-07,Overhead Press,42.5,5,8,
2026-10-07,Overhead Press,42.5,5,8,
2026-10-09,Barbell Row,57.5,8,7,
2026-10-09,Barbell Row,57.5,8,7,
2026-10-07,Pull-Up,0,7,8,
2026-10-07,Pull-Up,0,7,8,
2026-10-12,Back Squat,70,5,6,holiday week
2026-10-12,Back Squat,70,5,6,holiday week
2026-10-12,Bench Press,55,5,6,
2026-10-12,Bench Press,55,5,6,
2026-10-14,Deadlift,100,3,6,
2026-10-14,Overhead Press,35,5,6,
2026-10-14,Overhead Press,35,5,6,
2026-10-16,Barbell Row,50,8,6,
2026-10-19,Back Squat,95,5,7,
2026-10-19,Back Squat,95,5,7,
2026-10-19,Back Squat,95,5,7,
2026-10-19,Bench Press,67.5,5,7.5,
2026-10-19,Bench Press,67.5,5,7.5,
2026-10-19,Bench Press,67.5,5,7.5,
2026-10-23,Bench Press,62.5,8,7,
2026-10-23,Bench Press,62.5,8,7,
2026-10-23,Bench Press,62.5,8,7,
2026-10-21,Deadlift,125,3,8,
2026-10-21,Deadlift,125,3,8,
2026-10-21,Overhead Press,43.75,5,8,
2026-10-21,Overhead Press,43.75,5,8,
2026-10-21,Overhead Press,43.75,5,8,
2026-10-23,Barbell Row,60,8,7,
2026-10-23,Barbell Row,60,8,7,
2026-10-21,Pull-Up,0,7,8,
2026-10-21,Pull-Up,0,7,8,
2026-10-26,Back Squat,97.5,5,7,
2026-10-26,Back Squat,97.5,5,7,
2026-10-26,Back Squat,97.5,5,7,
2026-10-26,Bench Press,68.75,5,7.5,
2026-10-26,Bench Press,68.75,5,7.5,
2026-10-26,Bench Press,68.75,5,7.5,
2026-10-30,Bench Press,63.75,8,7,
2026-10-30,Bench Press,63.75,8,7,
2026-10-30,Bench Press,63.75,8,7,
2026-10-28,Deadlift,127.5,3,8,
2026-10-28,Deadlift,127.5,3,8,
2026-10-28,Overhead Press,43.75,5,8,
2026-10-28,Overhead Press,43.75,5,8,
2026-10-28,Overhead Press,43.75,5,8,
2026-10-30,Barbell Row,60,8,7,
2026-10-30,Barbell Row,60,8,7,
2026-10-28,Pull-Up,0,7,8,
2026-10-28,Pull-Up,0,7,8,
2026-11-02,Back Squat,97.5,5,7.5,
2026-11-02,Back Squat,97.5,5,7.5,
2026-11-02,Back Squat,97.5,5,7.5,
2026-11-02,Bench Press,70,5,7.5,
2026-11-02,Bench Press,70,5,7.5,
2026-11-02,Bench Press,70,5,7.5,
2026-11-06,Bench Press,65,8,7,
2026-11-06,Bench Press,65,8,7,
2026-11-06,Bench Press,65,8,7,
2026-11-04,Deadlift,105,3,8.5,had a cold
2026-11-04,Deadlift,105,3,8.5,had a cold
2026-11-04,Overhead Press,45,5,8,
2026-11-04,Overhead Press,45,5,8,
2026-11-04,Overhead Press,45,5,8,
2026-11-06,Barbell Row,60,8,7,
2026-11-06,Barbell Row,60,8,7,
2026-11-04,Pull-Up,0,8,8,
2026-11-04,Pull-Up,0,8,8,
2026-11-09,Back Squat,97.5,5,8,
2026-11-09,Back Squat,97.5,5,8,
2026-11-09,Back Squat,97.5,5,8,
2026-11-09,Bench Press,71.25,5,7.5,
2026-11-09,Bench Press,71.25,5,7.5,
2026-11-09,Bench Press,71.25,5,7.5,
2026-11-13,Bench Press,66.25,8,7,
2026-11-13,Bench Press,66.25,8,7,
2026-11-13,Bench Press,66.25,8,7,
2026-11-11,Deadlift,132.5,3,8,
2026-11-11,Deadlift,132.5,3,8,
2026-11-11,Overhead Press,45,5,8,
2026-11-11,Overhead Press,45,5,8,
2026-11-11,Overhead Press,45,5,8,
2026-11-13,Barbell Row,62.5,8,7,
2026-11-13,Barbell Row,62.5,8,7,
2026-11-11,Pull-Up,0,8,8,
2026-11-11,Pull-Up,0,8,8,
2026-11-16,Back Squat,97.5,5,8.5,
2026-11-16,Back Squat,97.5,5,8.5,
2026-11-16,Back Squat,97.5,5,8.5,
2026-11-16,Bench Press,72.5,5,7.5,
2026-11-16,Bench Press,72.5,5,7.5,
2026-11-16,Bench Press,72.5,5,7.5,
2026-11-20,Bench Press,67.5,8,7,volume challenge
2026-11-20,Bench Press,67.5,8,7,volume challenge
2026-11-20,Bench Press,67.5,8,7,volume challenge
2026-11-20,Bench Press,67.5,8,7,volume challenge
2026-11-20,Bench Press,67.5,8,7,volume challenge
2026-11-20,Bench Press,67.5,8,7,volume challenge
2026-11-20,Bench Press,67.5,8,7,volume challenge
2026-11-20,Bench Press,67.5,8,7,volume challenge
2026-11-18,Deadlift,135,3,8,
2026-11-18,Deadlift,135,3,8,
2026-11-18,Overhead Press,46.25,5,8,
2026-11-18,Overhead Press,46.25,5,8,
2026-11-18,Overhead Press,46.25,5,8,
2026-11-20,Barbell Row,62.5,8,7,
2026-11-20,Barbell Row,62.5,8,7,
2026-11-18,Pull-Up,0,8,8,
2026-11-18,Pull-Up,0,8,8,
2026-11-23,Back Squat,97.5,5,9.5,
2026-11-23,Back Squat,97.5,5,9.5,
2026-11-23,Back Squat,97.5,5,9.5,
2026-11-23,Bench Press,73.75,5,7.5,
2026-11-23,Bench Press,73.75,5,7.5,
2026-11-23,Bench Press,73.75,5,7.5,
2026-11-27,Bench Press,68.75,8,7,
2026-11-27,Bench Press,68.75,8,7,
2026-11-27,Bench Press,68.75,8,7,
2026-11-25,Deadlift,137.5,3,8,
2026-11-25,Deadlift,137.5,3,8,
2026-11-25,Overhead Press,46.25,5,8,
2026-11-25,Overhead Press,46.25,5,8,
2026-11-25,Overhead Press,46.25,5,8,
2026-11-27,Barbell Row,62.5,8,7,
2026-11-27,Barbell Row,62.5,8,7,
2026-11-25,Pull-Up,0,8,8,
2026-11-25,Pull-Up,0,8,8,
FILE:scriptshttps://www.aitopic.com/training_log.py
#!https://www.aitopic.com/usrhttps://www.aitopic.com/binhttps://www.aitopic.com/env python3
"""training_log.py - strength training log progress analyzer. Python 3.8+ standard library only.
Input: a CSV workout log with one row per set:
date,exercise,weight,reps[,rpe][,sets][,notes]
2026-09-01,Back Squat,80,5,7
- date: YYYY-MM-DD (also DD.MM.YYYY or DDhttps://www.aitopic.com/MMhttps://www.aitopic.com/YYYY)
- weight: external load per rep in --unit (kg default, or lb); 0 or empty = bodyweight (no e1RM)
- reps: reps done in the set (1-30 count for e1RM; more reps are counted as volume only)
- rpe: optional rate of perceived exertion 1-10
- sets: optional, repeats the row (for logs that write "3x5 at 80 kg" as one line)
Commas or semicolons as separator; decimal commas are accepted when the separator is a semicolon.
Per exercise and ISO week it computes: best estimated one-rep max (Epley, or Brzycki with --formula),
top set, hard sets (RPE >= 7, or every set when RPE is missing), and tonnage (weight x reps).
Across weeks it reports progress, plateaus, load spikes and recovery signals.
Usage:
training_log.py log.csv [--unit kg|lb] [--formula epley|brzycki] [--plateau-weeks 4]
[--spike 1.5] [--exercise "Back Squat"] [--since 2026-09-01]
[--format text|md|json|csv]
training_log.py --self-test
Exit: 0 no flags, 1 flags present, 2 unreadable input.
Flags:
S01 plateau: no new best e1RM for an exercise in the last --plateau-weeks weeks it was trained
S02 load spike: a week's hard sets for an exercise above --spike x the average of the 4 weeks before
S03 RPE creep: same or lower e1RM over 3+ weeks while average RPE rose by 1 or more
S04 no lighter week in 6+ consecutive training weeks (consider a deload)
S05 pushhttps://www.aitopic.com/pull imbalance: pressing hard sets more than 1.5x pulling hard sets over the log
S06 e1RM drop of 10% or more from the best for an exercise (check sleep, illness, technique, logging)
E01 rows that could not be parsed (skipped)
This is training feedback, not medical advice.
"""
import argparse, csv, io, json, re, statistics, sys
from datetime import date, datetime
PUSH = re.compile(r"bench|(?<!leg )press|push|dip|incline|overhead|ohp|chest fly", re.I)
PULL = re.compile(r"row|pull|chin|lat|face pull|deadlift|rdl|curl", re.I)
def parse_date(s):
s = s.strip()
for fmt in ("%Y-%m-%d", "%d.%m.%Y", "%dhttps://www.aitopic.com/%mhttps://www.aitopic.com/%Y"):
try:
return datetime.strptime(s, fmt).date()
except ValueError:
pass
raise ValueError("bad date %r" % s)
def num(s, comma_decimal=False):
s = (s or "").strip()
if not s:
return None
if comma_decimal:
s = s.replace(".", "").replace(",", ".") if re.match(r"^\d{1,3}(\.\d{3})+(,\d+)?$", s) else s.replace(",", ".")
return float(s)
def e1rm(weight, reps, formula="epley"):
"""Estimated one-rep max; None for bodyweight sets or reps outside 1..30."""
if not weight or weight <= 0 or reps is None or reps < 1 or reps > 30:
return None
if reps == 1:
return float(weight)
if formula == "brzycki":
return weight * 36.0 https://www.aitopic.com/ (37.0 - reps)
return weight * (1 + reps https://www.aitopic.com/ 30.0)
def week_key(d):
y, w, _ = d.isocalendar()
return "%d-W%02d" % (y, w)
def read_log(text):
sample = text[:2000]
delim = ";" if sample.count(";") > sample.count(",") else ","
rows, errors = [], []
rd = csv.DictReader(io.StringIO(text), delimiter=delim)
if not rd.fieldnames:
raise ValueError("empty file")
fields = {f.strip().lower(): f for f in rd.fieldnames}
alias = {"weight": ["weight", "load", "kg", "lb", "weight_kg", "weight_lb"], "reps": ["reps", "rep"], "exercise": ["exercise", "lift", "movement"],
"date": ["date", "day"], "rpe": ["rpe"], "sets": ["sets"], "notes": ["notes", "note", "comment"]}
col = {}
for k, names in alias.items():
for n in names:
if n in fields:
col[k] = fields[n]
break
missing = [k for k in ("date", "exercise", "weight", "reps") if k not in col]
if missing:
raise ValueError("missing column(s): " + ", ".join(missing))
for i, r in enumerate(rd, start=2):
try:
d = parse_date(r[col["date"]])
ex = " ".join((r[col["exercise"]] or "").split())
if not ex:
raise ValueError("no exercise")
w = num(r.get(col["weight"]), delim == ";") or 0.0
reps = num(r.get(col["reps"]), delim == ";")
if reps is None or reps <= 0 or w < 0:
raise ValueError("bad repshttps://www.aitopic.com/weight")
rpe = num(r.get(col.get("rpe", ""), ""), delim == ";") if "rpe" in col else None
if rpe is not None and not 1 <= rpe <= 10:
raise ValueError("rpe out of range")
n = int(num(r.get(col["sets"]), delim == ";") or 1) if "sets" in col else 1
for _ in range(max(1, n)):
rows.append(dict(date=d, exercise=ex, weight=w, reps=int(reps), rpe=rpe))
except (ValueError, TypeError, KeyError) as e:
errors.append("line %d: %s" % (i, e))
return rows, errors
def analyze(rows, errors=(), unit="kg", formula="epley", plateau_weeks=4, spike=1.5):
ex_weeks = {}
all_weeks = sorted({week_key(r["date"]) for r in rows})
for r in rows:
wk = week_key(r["date"])
s = ex_weeks.setdefault(r["exercise"], {}).setdefault(wk, dict(e1rm=None, top=None, hard=0, sets=0, tonnage=0.0, rpes=[]))
est = e1rm(r["weight"], r["reps"], formula)
if est is not None and (s["e1rm"] is None or est > s["e1rm"]):
s["e1rm"], s["top"] = est, "%g x %d" % (r["weight"], r["reps"])
s["sets"] += 1
s["tonnage"] += r["weight"] * r["reps"]
if r["rpe"] is None or r["rpe"] >= 7:
s["hard"] += 1
if r["rpe"] is not None:
s["rpes"].append(r["rpe"])
flags, exercises = [], []
def flag(code, ex, detail):
flags.append(dict(code=code, exercise=ex, detail=detail))
for ex in sorted(ex_weeks):
wk = ex_weeks[ex]
keys = sorted(wk)
series = [(k, wk[k]["e1rm"]) for k in keys if wk[k]["e1rm"] is not None]
info = dict(exercise=ex, weeks=len(keys), sets=sum(wk[k]["sets"] for k in keys), tonnage=round(sum(wk[k]["tonnage"] for k in keys), 1))
if series:
first, best = series[0][1], max(v for _, v in series)
best_week = [k for k, v in series if v == best][0]
last = series[-1][1]
info.update(first_e1rm=round(first, 1), best_e1rm=round(best, 1), best_week=best_week, last_e1rm=round(last, 1),
change_pct=round(100 * (last - first) https://www.aitopic.com/ first, 1))
if len(series) > plateau_weeks:
recent = [v for _, v in series[-plateau_weeks:]]
before = max(v for _, v in series[:-plateau_weeks])
if max(recent) <= before:
flag("S01", ex, "no new best e1RM in the last %d training weeks (best %.1f %s in %s)" % (plateau_weeks, best, unit, best_week))
if last <= best * 0.9 and len(series) >= 3:
flag("S06", ex, "latest e1RM %.1f %s is %.0f%% below the best %.1f %s" % (last, unit, 100 * (1 - last https://www.aitopic.com/ best), best, unit))
if len(series) >= 3:
tail = series[-3:]
rp = [statistics.mean(wk[k]["rpes"]) if wk[k]["rpes"] else None for k, _ in tail]
if None not in rp and rp[-1] - rp[0] >= 1 and tail[-1][1] <= tail[0][1]:
flag("S03", ex, "average RPE %.1f -> %.1f over %s..%s while e1RM did not improve" % (rp[0], rp[-1], tail[0][0], tail[-1][0]))
for i, k in enumerate(keys):
prev = [wk[p]["hard"] for p in keys[max(0, i - 4):i]]
if len(prev) >= 3 and statistics.mean(prev) > 0 and wk[k]["hard"] > spike * statistics.mean(prev) and wk[k]["hard"] - statistics.mean(prev) >= 3:
flag("S02", ex, "%s: %d hard sets vs %.1f average of the previous weeks" % (k, wk[k]["hard"], statistics.mean(prev)))
info["weekly"] = [dict(week=k, e1rm=round(wk[k]["e1rm"], 1) if wk[k]["e1rm"] else None, top_set=wk[k]["top"], hard_sets=wk[k]["hard"],
sets=wk[k]["sets"], tonnage=round(wk[k]["tonnage"], 1),
avg_rpe=round(statistics.mean(wk[k]["rpes"]), 1) if wk[k]["rpes"] else None) for k in keys]
exercises.append(info)
# deload check on total hard sets per week across all exercises
totals = []
for k in all_weeks:
totals.append(sum(ex_weeks[e][k]["hard"] for e in ex_weeks if k in ex_weeks[e]))
run = 0
for i, t in enumerate(totals):
ref = statistics.mean(totals[max(0, i - 4):i]) if i else t
run = 0 if (i and t <= 0.7 * ref) else run + 1
if run >= 6:
flag("S04", "-", "%d training weeks in a row without a lighter week (hard sets per week: %s)" % (run, ", ".join(str(t) for t in totals[-run:])))
push = sum(r["rpe"] is None or r["rpe"] >= 7 for r in rows if PUSH.search(r["exercise"]) and not PULL.search(r["exercise"]))
pull = sum(r["rpe"] is None or r["rpe"] >= 7 for r in rows if PULL.search(r["exercise"]))
if pull and push > 1.5 * pull or (push >= 10 and not pull):
flag("S05", "-", "pressing hard sets %d vs pulling hard sets %d" % (push, pull))
for e in errors:
flag("E01", "-", e)
order = ["S06", "S02", "S03", "S01", "S04", "S05", "E01"]
flags.sort(key=lambda f: (order.index(f["code"]), f["exercise"]))
summary = dict(rows=len(rows), skipped=len(errors), exercises=len(exercises), weeks=len(all_weeks),
first_date=min(r["date"] for r in rows).isoformat() if rows else None,
last_date=max(r["date"] for r in rows).isoformat() if rows else None,
hard_sets_per_week=totals, unit=unit, formula=formula, push_hard_sets=push, pull_hard_sets=pull)
return dict(summary=summary, exercises=exercises, flags=flags)
def render_text(r):
s = r["summary"]
out = ["Strength training progress (%s, e1RM %s)" % (s["unit"], s["formula"]),
"- %d sets, %d exercises, %d weeks (%s to %s); hard sets per week: %s" % (s["rows"], s["exercises"], s["weeks"], s["first_date"], s["last_date"], ", ".join(map(str, s["hard_sets_per_week"]))), ""]
out.append("%-22s %6s %8s %8s %8s %7s %9s" % ("Exercise", "weeks", "first", "best", "latest", "change", "tonnage"))
for e in r["exercises"]:
if "best_e1rm" in e:
out.append("%-22s %6d %8.1f %8.1f %8.1f %6.1f%% %9.0f" % (e["exercise"][:22], e["weeks"], e["first_e1rm"], e["best_e1rm"], e["last_e1rm"], e["change_pct"], e["tonnage"]))
else:
out.append("%-22s %6d %8s %8s %8s %7s %9.0f" % (e["exercise"][:22], e["weeks"], "-", "-", "-", "bw", e["tonnage"]))
out += ["", "Flags" if r["flags"] else "Flags: none"]
out += [" %s %-16s %s" % (f["code"], f["exercise"][:16], f["detail"]) for f in r["flags"]]
out.append("Training feedback only, not medical advice.")
return "\n".join(out)
def render_md(r):
s = r["summary"]
out = ["## Training progress %s to %s" % (s["first_date"], s["last_date"]), "",
"%d sets over %d weeks, %d exercises. e1RM by %s, unit %s." % (s["rows"], s["weeks"], s["exercises"], s["formula"], s["unit"]), "",
"| Exercise | Weeks | First e1RM | Best e1RM | Latest | Change |", "|---|---:|---:|---:|---:|---:|"]
for e in r["exercises"]:
if "best_e1rm" in e:
out.append("| %s | %d | %.1f | %.1f (%s) | %.1f | %+.1f%% |" % (e["exercise"], e["weeks"], e["first_e1rm"], e["best_e1rm"], e["best_week"], e["last_e1rm"], e["change_pct"]))
out += ["", "| Flag | Exercise | Detail |", "|---|---|---|"] + ["| %s | %s | %s |" % (f["code"], f["exercise"], f["detail"]) for f in r["flags"]]
return "\n".join(out)
def render_csv(r):
buf = io.StringIO()
w = csv.writer(buf, lineterminator="\n")
w.writerow(["exercise", "week", "e1rm", "top_set", "hard_sets", "sets", "tonnage", "avg_rpe"])
for e in r["exercises"]:
for k in e["weekly"]:
w.writerow([e["exercise"], k["week"], k["e1rm"] if k["e1rm"] is not None else "", k["top_set"] or "", k["hard_sets"], k["sets"], k["tonnage"], k["avg_rpe"] if k["avg_rpe"] is not None else ""])
return buf.getvalue().rstrip("\n")
def run(argv):
ap = argparse.ArgumentParser(description="Analyze a strength training CSV log.")
ap.add_argument("log", nargs="?")
ap.add_argument("--unit", choices=["kg", "lb"], default="kg")
ap.add_argument("--formula", choices=["epley", "brzycki"], default="epley")
ap.add_argument("--plateau-weeks", type=int, default=4)
ap.add_argument("--spike", type=float, default=1.5)
ap.add_argument("--exercise", action="append", help="only these exercises (repeatable, case-insensitive)")
ap.add_argument("--since", help="ignore sets before this date (YYYY-MM-DD)")
ap.add_argument("--format", choices=["text", "md", "json", "csv"], default="text")
ap.add_argument("--self-test", action="store_true")
a = ap.parse_args(argv)
if a.self_test:
return self_test()
if not a.log:
ap.print_usage(sys.stderr)
return 2
try:
with open(a.log, encoding="utf-8-sig") as fh:
rows, errors = read_log(fh.read())
except (OSError, ValueError, UnicodeDecodeError) as e:
print("error: cannot read log: %s" % e, file=sys.stderr)
return 2
if a.since:
cut = parse_date(a.since)
rows = [r for r in rows if r["date"] >= cut]
if a.exercise:
wanted = {x.lower() for x in a.exercise}
rows = [r for r in rows if r["exercise"].lower() in wanted]
if not rows:
print("error: no usable rows (%d skipped)" % len(errors), file=sys.stderr)
return 2
r = analyze(rows, errors, a.unit, a.formula, a.plateau_weeks, a.spike)
if a.format == "json":
print(json.dumps(r, indent=2, default=str))
else:
print({"text": render_text, "md": render_md, "csv": render_csv}[a.format](r))
return 1 if r["flags"] else 0
def self_test():
checks = 0
def ok(cond, msg):
nonlocal checks
checks += 1
if not cond:
raise AssertionError(msg)
ok(abs(e1rm(100, 5) - 116.667) < 0.01, "epley 100x5")
ok(abs(e1rm(100, 5, "brzycki") - 112.5) < 0.01, "brzycki 100x5")
ok(e1rm(100, 1) == 100 and e1rm(0, 10) is None and e1rm(50, 40) is None, "edge cases")
ok(week_key(date(2026, 12, 31)) == "2026-W53" and week_key(date(2027, 1, 4)) == "2027-W01", "iso weeks")
ok(parse_date("05.10.2026") == date(2026, 10, 5), "dotted date")
rows, err = read_log("date;exercise;weight;reps;rpe\n2026-09-01;Squat;82,5;5;7\n2026-09-01;Squat;x;5;7\n")
ok(len(rows) == 1 and rows[0]["weight"] == 82.5 and len(err) == 1, "semicolon + decimal comma + bad row")
rows, _ = read_log("date,exercise,weight,reps,sets\n2026-09-01,Bench Press,60,5,3\n")
ok(len(rows) == 3, "sets column expands rows")
def mk(weeks, w0, step, ex="Back Squat", sets=3, rpe=7):
out = []
for i in range(weeks):
d = date.fromordinal(date(2026, 9, 7).toordinal() + 7 * i)
for _ in range(sets):
out.append(dict(date=d, exercise=ex, weight=w0 + step(i), reps=5, rpe=rpe))
return out
r = analyze(mk(8, 80, lambda i: 2.5 * i))
ok(not [f for f in r["flags"] if f["code"] == "S01"], "steady progress is no plateau")
ok(r["exercises"][0]["change_pct"] > 0, "progress positive")
r = analyze(mk(8, 80, lambda i: min(i, 3) * 2.5))
ok([f for f in r["flags"] if f["code"] == "S01"], "plateau flagged")
ok([f for f in r["flags"] if f["code"] == "S04"], "8 weeks without deload flagged")
rows = mk(4, 80, lambda i: 0, sets=3) + [dict(date=date(2026, 10, 5), exercise="Back Squat", weight=80, reps=5, rpe=8) for _ in range(9)]
ok([f for f in analyze(rows)["flags"] if f["code"] == "S02"], "load spike flagged")
drop = mk(4, 100, lambda i: 0) + mk(1, 85, lambda i: 0)
drop[-1]["date"] = drop[-2]["date"] = drop[-3]["date"] = date(2026, 10, 12)
ok([f for f in analyze(drop)["flags"] if f["code"] == "S06"], "e1RM drop flagged")
bench = mk(4, 60, lambda i: 0, ex="Bench Press", sets=4) + mk(4, 50, lambda i: 0, ex="Barbell Row", sets=2)
ok([f for f in analyze(bench)["flags"] if f["code"] == "S05"], "pushhttps://www.aitopic.com/pull imbalance flagged")
ok(not PUSH.search("Leg Press") and PUSH.search("Overhead Press"), "leg press is not a push")
print("self-test OK: %d checks" % checks)
return 0
if __name__ == "__main__":
sys.exit(run(sys.argv[1:]))
Comments & Questions (0)
No comments yet
Be the first to comment!