Add MeasuredDate column to all CSV files
CHANGES: - Added MeasuredDate as first column in regional.csv - Added MeasuredDate as first column in muscle_balance.csv - Updated README to document new column structure BENEFITS: ✅ Track regional changes over time (e.g., Arms fat % across scans) ✅ Easy time-series analysis with pandas/Excel ✅ Filter by date range for progress tracking ✅ Consistent date column across all 3 CSV files ✅ Enables queries like: 'Show me trunk fat % over last 6 months' EXAMPLE USAGE: import pandas as pd regional = pd.read_csv('regional.csv') arms = regional[regional['Region'] == 'Arms'] # Now you can track Arms progress over time! Each scan now adds: - 1 row to overall.csv - 6 rows to regional.csv (one per region) - 6 rows to muscle_balance.csv (one per limb comparison)
This commit is contained in:
parent
130f0ba994
commit
c7d2e32d7d
2 changed files with 11 additions and 5 deletions
|
|
@ -578,12 +578,13 @@ def process_single_pdf(pdf_path, height_in, weight_lb, outdir, batch_mode=False)
|
|||
write_or_append_csv(os.path.join(outdir, "overall.csv"), overall_row, overall_cols)
|
||||
|
||||
# Regional table
|
||||
regional_cols = ["Region","FatPercent","LeanPercent","TotalMass_lb","FatTissue_lb","LeanTissue_lb","BMC_lb"]
|
||||
regional_cols = ["MeasuredDate","Region","FatPercent","LeanPercent","TotalMass_lb","FatTissue_lb","LeanTissue_lb","BMC_lb"]
|
||||
reg_rows = []
|
||||
for name, r in d.get("regional", {}).items():
|
||||
# Calculate lean percentage (lean tissue only, not including BMC - matches BodySpec report)
|
||||
lean_pct = round(100 * r["lean_tissue_lb"] / r["total_mass_lb"], 1) if r["total_mass_lb"] > 0 else None
|
||||
reg_rows.append({
|
||||
"MeasuredDate": measured_date,
|
||||
"Region": name,
|
||||
"FatPercent": r["fat_percent"],
|
||||
"LeanPercent": lean_pct,
|
||||
|
|
@ -600,10 +601,11 @@ def process_single_pdf(pdf_path, height_in, weight_lb, outdir, batch_mode=False)
|
|||
df_regional.to_csv(regional_path, index=False)
|
||||
|
||||
# Muscle balance
|
||||
mb_cols = ["Region","FatPercent","TotalMass_lb","FatMass_lb","LeanMass_lb","BMC_lb"]
|
||||
mb_cols = ["MeasuredDate","Region","FatPercent","TotalMass_lb","FatMass_lb","LeanMass_lb","BMC_lb"]
|
||||
mb_rows = []
|
||||
for name, r in d.get("muscle_balance", {}).items():
|
||||
mb_rows.append({
|
||||
"MeasuredDate": measured_date,
|
||||
"Region": name,
|
||||
"FatPercent": r["fat_percent"],
|
||||
"TotalMass_lb": r["total_mass_lb"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue