Created
February 4, 2020 19:48
-
-
Save firaswehbe/deb2926c0fd2148f1e8a01fb852ad457 to your computer and use it in GitHub Desktop.
Extracting your weight from Apple Health
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 | |
# Export the data from Apple Health | |
# You will get an export.zip file | |
# Unzip that file. You will get a bunch of files use export.xml | |
import xml.etree.ElementTree as ET | |
tree = ET.parse('export.xml') | |
root = tree.getroot() | |
# If you want weights from all sources remove the last condition in the expression | |
for x in root: | |
if x.tag == 'Record' and x.attrib['type'] == 'HKQuantityTypeIdentifierBodyMass' and x.attrib['sourceName'] == 'RENPHO': | |
print('{0},{1}'.format(x.attrib['startDate'],x.attrib['value'])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment