Skip to content

Instantly share code, notes, and snippets.

@firaswehbe
Created February 4, 2020 19:48
Show Gist options
  • Save firaswehbe/deb2926c0fd2148f1e8a01fb852ad457 to your computer and use it in GitHub Desktop.
Save firaswehbe/deb2926c0fd2148f1e8a01fb852ad457 to your computer and use it in GitHub Desktop.
Extracting your weight from Apple Health
#!/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