Created
April 25, 2017 08:53
-
-
Save feclare/9ce446a640ac1b8854456a4da468dc05 to your computer and use it in GitHub Desktop.
Simple script to transform libra csv file to openscale format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Simple script to transform libra csv file to openscale format | |
""" | |
import sys | |
import csv | |
from dateutil.parser import parse | |
if len(sys.argv) != 2: | |
print "Missing file to transform\n" | |
sys.exit(1) | |
r = csv.reader(file(sys.argv[1]), delimiter=";") | |
writer = csv.writer(file("openScale_data_Libra.csv", "w"), delimiter=",") | |
for w in r: | |
if len(w) == 0 or w[0].startswith("#"): | |
continue | |
time = w[0] | |
weight = w[1] | |
comment = w[5] | |
d = parse(time) | |
writer.writerow([d.strftime('%d.%m.%Y %H:%M'), weight, 0.0, 0.0, 0.0, 0.0, 0.0, comment]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment