Mastering Health Data Extraction on Your iPhone Effortlessly
Written on
Chapter 1: Understanding the Health App
The Health app on your iPhone is a robust tool packed with features, making it challenging to locate specific information amid the vast amount of data it collects. With Apple’s commitment to enhancing health tracking, the situation can become even more overwhelming.
Fortunately, there is a straightforward and cost-free method to navigate this complexity. By utilizing Shortcuts, you can extract specific health data from your iPhone and even automate the process for convenience.
In this guide, I'll demonstrate how to:
- Extract step counts from your Apple Watch and iPhone.
- Import the data into Numbers for analysis.
- Utilize a pivot table to visualize your findings.
The simplicity of this shortcut lies in its design: a single action retrieves the data, and a loop converts it into CSV format. This process is entirely free for iPhone users.
What We Will Retrieve
Health information is exclusively accessible on your iPhone; shortcut actions for fetching this data are not available on iPads. For this demonstration, I will extract step counts recorded by both my Apple Watch and iPhone.
The data fields we will focus on include:
- Source: The device that collected the data.
- Start Date: When the data collection began.
- Stop Date: When the data collection ended.
- Duration: The time span of the activity.
- Units: The measurement units used.
- Values: The actual data point.
Creating the Shortcut
To create and run this Shortcut, follow these steps on your iPhone:
- In the Shortcuts app, type "health" in the search bar. Select the "Find All Health Samples" action and adjust the type to "Steps," adding a filter for your preferred start date.
- Next, incorporate a "Repeat with each item" action, which should automatically include "Health Samples."
- Within the loop, add a Text action. Tap the Text field, select "Select Variable," and choose "Repeat Item," then repeat for each required field, separating them with commas.
- After the loop, add another Text action, selecting "Repeat Results."
- Finally, insert a Quick Look action to use the share menu for copying the retrieved data to your clipboard.
Note: While you can extract data for a range of dates, this may slow down the retrieval process. The first run of the shortcut may take longer, but subsequent attempts will be quicker.
Importing Your Data into Numbers
Once you've run the shortcut, there will be a brief pause before the Quick Look window appears. Use the share menu to copy the CSV text.
What’s next? Open Numbers (available for free on iPhone, iPad, and Mac), select a blank template, click on cell B2, and paste the data.
Organize the data by labeling the columns and removing column A. Adjust the column widths for a tidy appearance.
Check your Health app for the step count corresponding to your selected day. You might notice that the total in the Steps column is approximately double what the Health app displays.
Understanding Your Data
In my case, the steps data originates from two devices: my Apple Watch and iPhone. It’s essential to differentiate the sources. A pivot table can simplify this analysis.
Let’s walk through the steps to create one. You can also download my Numbers spreadsheet for reference.
- Tap any cell in the table and select the green “Cell” button.
- A menu will appear; choose “Create Pivot Table.”
- Navigate to the newly created pivot table worksheet. Tap the icon next to the paintbrush.
- Move the Source field information to the columns section of the pivot table.
- Place the Start Date in the rows section and the Value in the values section.
Look at the results in columns B and C; the figures should now align more closely with what you observed in the Health app. It appears that the app processes data from various sources differently.
Final Thoughts
You now have the ability to extract and analyze health data that is meaningful to you, with the option to automate the process. No longer will you need to wait for Apple to release a new iOS version for updates.
While it's understandable why Apple might obscure raw health data—given its collection from diverse sources using varying parameters—this complexity reflects the reality that determining accurate health information can be challenging.
The uncertainty it creates is something Apple addresses through machine learning, though it doesn't completely resolve it. Consulting a medical professional before relying solely on this data for health decisions is always advisable.
Explore more of my articles on Apple Shortcuts:
Apple Shortcuts
This video discusses over 25 hidden features and tips for Apple Health that can enhance your health tracking experience.
Learn how to export heart data from Apple Health to CSV and visualize graphs of heart rate ranges and averages for better insights.