mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-13 20:24:14 +02:00
Updated Useful import scripts (markdown)
@@ -141,3 +141,39 @@ if __name__ == '__main__':
|
|||||||
weight = entry['weight']['weight'] / 1000
|
weight = entry['weight']['weight'] / 1000
|
||||||
writer.writerow({'dateTime': timestamp, 'weight': weight})
|
writer.writerow({'dateTime': timestamp, 'weight': weight})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Google Fit Takeout --> openScale CSV file
|
||||||
|
|
||||||
|
by sainigma see https://github.com/oliexdev/openScale/issues/1040
|
||||||
|
|
||||||
|
```python
|
||||||
|
#!/usr/bin/env python
|
||||||
|
import csv
|
||||||
|
from dateutil.parser import parse
|
||||||
|
|
||||||
|
with open('Daily activity metrics.csv', newline='') as input_csv:
|
||||||
|
csv_reader = csv.reader(input_csv, delimiter=',')
|
||||||
|
|
||||||
|
rows = []
|
||||||
|
|
||||||
|
for row in csv_reader:
|
||||||
|
rows.append(row)
|
||||||
|
|
||||||
|
headers = rows[0]
|
||||||
|
data = rows[1:]
|
||||||
|
|
||||||
|
date_idx = headers.index('Date')
|
||||||
|
weight_idx = headers.index('Average weight (kg)')
|
||||||
|
|
||||||
|
with open('openscale_data.csv', 'w', newline='', encoding='utf-8') as output_csv:
|
||||||
|
output_writer = csv.writer(output_csv, delimiter=',')
|
||||||
|
|
||||||
|
output_writer.writerow(["dateTime", "weight"])
|
||||||
|
|
||||||
|
for fragment in data:
|
||||||
|
date = fragment[date_idx]
|
||||||
|
weight = fragment[weight_idx]
|
||||||
|
|
||||||
|
if (weight and date):
|
||||||
|
output_writer.writerow([parse(date).strftime('%d.%m.%Y 08:00'), round(float(weight), 2)])
|
||||||
|
```
|
||||||
|
Reference in New Issue
Block a user