Skip to content

workouts/measurements: full float64 precision in CSV/JSON for calories, distance, weight #26

@DTTerastar

Description

@DTTerastar

Severity

minor

Summary

Several numeric columns are emitted at full float64 precision in CSV and JSON, producing noisy values like 550.09729003906 and 107.35000000000001. Markdown rounds the same fields to a sensible number of decimals, so the rounding helpers exist — they just aren't applied on the structured paths. Same family of bug as #21 but for workouts and measurements.

Reproduce

HEAD b58068351a2edeb90f0d26b9098f04e85db225ee.

$ /tmp/qa-bin/withings-export workouts --since 1y --format csv | head -3
date,start,end,category,...,calories,steps,distance_m,elevation_m,...
2025-04-25,...,lift_weights,...,550.09729003906,207,157.71188354492,0,...
2025-04-25,...,bicycling,...,519.41967773438,924,703.98931884766,0,...

$ /tmp/qa-bin/withings-export workouts --since 90d --format json | jq '.[0].data'
{
  "calories": 435.7490234375,
  "manual_distance": 4575.8657226562,
  "manual_calories": 315.9172668457,
  "distance": 4162.22265625,
  ...
}

$ /tmp/qa-bin/withings-export measurements --since 30d --format csv | head -2
date,type,type_code,value,device_id,grp_id
2026-03-26T06:55:43-04:00,fat_free_mass_kg,5,72.84400000000001,...

$ /tmp/qa-bin/withings-export measurements --since 30d --format json | jq '.[0].value'
72.84400000000001

Expected

  • workouts calories, manual_calories: round to 1 decimal (matches the 1099 / 806.75 style that activity --format json already uses for totalcalories).
  • workouts distance, manual_distance: round to 2 decimals (matches activity distance_m: 11395.42).
  • measurements value: round trailing-9s/trailing-1s float noise — Withings stores 3 decimal places at most for weight (107.35, not 107.35000000000001); %g or %.3f would fix it. Note weight_kg=107.35 and fat_ratio_pct=32.143 already render fine — only certain unit-converted values exhibit the noise.

The same fmtRound/fmtFloat1 helpers used by markdown should be applied on the CSV/JSON serializers.

Metadata

Metadata

Assignees

Labels

area:format--format markdown/json/csv and codec behavior.kind:bugObserved behavior diverges from documented behavior.priority:mediumReproducible bug or gap with a workaround, or a well-scoped enhancement clearly in charter.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions