Created
May 6, 2017 02:57
-
-
Save xiangzhi/481a2f47e116cbd3990e5507422b6f32 to your computer and use it in GitHub Desktop.
code to parse fitbit exercise data from website
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
from dateutil import parser | |
import csv | |
csvfile = open('data.csv','wb') | |
writer = csv.writer(csvfile, delimiter=',') | |
with open('base.data') as f: | |
for line in f: | |
splited_line = line.split('\t') | |
exercise_type = splited_line[1] | |
if(exercise_type.startswith('Yoga')): | |
print(splited_line) | |
guessed_time = parser.parse(splited_line[0]) | |
date_str = '{:%m/%d/%y}'.format(guessed_time) | |
time_str = '{:%I:%M%p}'.format(guessed_time) | |
print(time_str) | |
location = 'Outside' | |
total_time = '0:' + splited_line[4] | |
print_str = [date_str,time_str,location, total_time] | |
writer.writerow(print_str) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment