mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-09 18:26:38 +02:00
Updated Useful import scripts (markdown)
@@ -63,3 +63,49 @@ for w in r:
|
|||||||
d = parse(time)
|
d = parse(time)
|
||||||
writer.writerow([d.strftime('%d.%m.%Y %H:%M'), weight, 0.0, 0.0, 0.0, 0.0, 0.0, comment])
|
writer.writerow([d.strftime('%d.%m.%Y %H:%M'), weight, 0.0, 0.0, 0.0, 0.0, 0.0, comment])
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## openScale CSV file --> Garmin format
|
||||||
|
|
||||||
|
by jowlo see https://github.com/oliexdev/openScale/issues/777
|
||||||
|
|
||||||
|
```python
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
"""
|
||||||
|
Simple script to transform openscale csv export files to a format accepted by garmin connect at
|
||||||
|
https://connect.garmin.com/modern/import-data
|
||||||
|
|
||||||
|
Note: When importing the language needs to be set to English, otherwise the import fails.
|
||||||
|
Set everything to metric units and to YYYY-MM-DD date format.
|
||||||
|
|
||||||
|
If you want to compute BMI for the file give your height (im meters) as second parameter.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import csv
|
||||||
|
from dateutil.parser import parse
|
||||||
|
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print "Missing file to transform\n"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
bmi = lambda size: 0;
|
||||||
|
if len(sys.argv) == 3:
|
||||||
|
bmi = lambda weight: weight/(float(sys.argv[2])**2)
|
||||||
|
|
||||||
|
|
||||||
|
with open("openScale_garmin_connect_import.csv", "wb") as outfile, open(sys.argv[1], "r") as infile:
|
||||||
|
|
||||||
|
reader = csv.DictReader(infile, delimiter=",")
|
||||||
|
writer = csv.writer(outfile, delimiter=",")
|
||||||
|
|
||||||
|
outfile.write("Body\n")
|
||||||
|
outfile.write("Date,Weight,BMI,Fat\n")
|
||||||
|
for row in reader:
|
||||||
|
writer.writerow([
|
||||||
|
parse(row["dateTime"]).strftime('%Y-%m-%d'),
|
||||||
|
row["weight"],
|
||||||
|
bmi(float(row["weight"])),
|
||||||
|
row["fat"]
|
||||||
|
])
|
||||||
|
```
|
Reference in New Issue
Block a user