Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save xiangzhi/481a2f47e116cbd3990e5507422b6f32 to your computer and use it in GitHub Desktop.
Save xiangzhi/481a2f47e116cbd3990e5507422b6f32 to your computer and use it in GitHub Desktop.
code to parse fitbit exercise data from website
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