Created
August 19, 2015 13:10
-
-
Save btroia/50a8430f371137d128bd to your computer and use it in GitHub Desktop.
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
import json | |
import datetime as dt | |
from pprint import pprint | |
# change this to the JSON file you want to analyze | |
json_data = open('data/basis-data-2014-09-15-sleep.json') | |
data = json.load(json_data) | |
json_data.close() | |
total_light_mins = 0 | |
total_rem_mins = 0 | |
total_deep_mins = 0 | |
total_interrupt_mins = 0 | |
total_unknown_mins = 0 | |
total_actual_seconds = 0 | |
activities = data["content"]["activities"]; | |
for z in range(0, len(activities)): | |
if activities[z]["type"] == "sleep": | |
print z, "start: ", activities[z]["start_time"]["iso"] | |
print z, "end: ", activities[z]["end_time"]["iso"] | |
print z, " light mins: ", activities[z]["sleep"]["light_minutes"] | |
print z, " rem mins: ", activities[z]["sleep"]["rem_minutes"] | |
print z, " deep mins: ", activities[z]["sleep"]["deep_minutes"] | |
print z, " interruption mins: ", activities[z]["sleep"]["interruption_minutes"] | |
print z, " unknown mins: ", activities[z]["sleep"]["unknown_minutes"] | |
total_light_mins += activities[z]["sleep"]["light_minutes"] | |
total_rem_mins += activities[z]["sleep"]["rem_minutes"] | |
total_deep_mins += activities[z]["sleep"]["deep_minutes"] | |
total_interrupt_mins += activities[z]["sleep"]["interruption_minutes"] | |
total_unknown_mins += activities[z]["sleep"]["unknown_minutes"] | |
total_actual_seconds += activities[z]["actual_seconds"] | |
print "total light: ", total_light_mins | |
print "total rem: ", total_rem_mins | |
print "total deep: ", total_deep_mins | |
print "total interrupt: ", total_interrupt_mins | |
print "total unknown: ", total_unknown_mins | |
print "total sleep: ", total_light_mins + total_rem_mins + total_deep_mins + total_interrupt_mins + total_unknown_mins | |
print "actual minutes: ", total_actual_seconds / 60 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment