Skip to content

Import scripts in FAQ and wiki #669

@Martin1887

Description

@Martin1887

This is a good app to migrate from other proprietary ones so having migration guides would be great for this purpose.

As example, I provide a script to migrate from MiFit 'BODY' file, but note that only weight and timestamp are migrated because I had not other statistics. The MiFit 'BODY' file header is included in the script for reference. I had also to remove a weird UTF-8 character at the start of the file before running this script.

#!/usr/bin/python

import argparse
import csv
import datetime

OPENSCALE_HEADER = '"biceps","bone","caliper1","caliper2","caliper3","calories","chest","comment","dateTime","fat","hip","lbm","muscle","neck","thigh","visceralFat","waist","water","weight"'

_MIFIT_BODY_HEADER = 'timestamp,weight,height,bmi,fatRate,bodyWaterRate,boneMass,metabolism,muscleRate,visceralFat,impedance'

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('mifit_BODY_csv_file_path')
    parser.add_argument('output_path')
    
    args = parser.parse_args()
    
    with open(args.mifit_BODY_csv_file_path, 'r') as inp:
        reader = csv.DictReader(inp)
        with open(args.output_path, 'w') as outp:
            writer = csv.DictWriter(outp, OPENSCALE_HEADER.replace('"', '').split(','))
            outp.write(f'{OPENSCALE_HEADER}\n')
            
            for line in reader:
                timestamp = int(line['timestamp'])
                output_date = datetime.datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M')
                weight = line['weight']
                writer.writerow({'dateTime': output_date, 'weight': weight})
                

At least this script could be included in the FAQ and the wiki.

Regards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementIndicates new feature requests

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions