Import Apple Health data in Garmin Connect

My newest toy is a Garmin Fenix 5 Plus, a very nice smartwatch. In the past, I recorded my steps and other activity data using the Apple Health app on my iPhone. This means that I had a few years worth of activity data that I wanted to move from my Apple Health app to Garmin Connect.

However, that turned out to be not that straight-forward. Garmin only allows you to import GPX, FIT or Fitbit CSV files, not any Apple Health data.

So how to import the data anyway? We’ll first have to convert our Apple Health data to an intermediate format, such as Fitbit CSV data. The Apple Health data is in an XML format and this can be used to generate Fitbit CSV files. These CSV files can then be imported into Garmin Connect.

Here is an example of Apples health data (export.xml):

[..]
 <Record type="HKQuantityTypeIdentifierBodyTemperature" sourceName="Health" sourceVersion="9.3.2" unit="degC" creationDate="2016-07-25 01:11:39 +0200" startDate="2016-07-25 01:11:00 +0200" endDate="2016-07-25 01:11:00 +0200" value="36.5">
  <MetadataEntry key="HKWasUserEntered" value="1"/>
 </Record>
 <Record type="HKQuantityTypeIdentifierStepCount" sourceName="iPhone" sourceVersion="9.0.2" device="<<HKDevice: 0x128f84a40>, name:iPhone, manufacturer:Apple, model:iPhone, hardware:iPhone6,2, software:9.0.2>" unit="count" creationDate="2015-10-14 21:40:53 +0200" startDate="2015-10-14 21:07:20 +0200" endDate="2015-10-14 21:07:40 +0200" value="11"/>
 <Record type="HKQuantityTypeIdentifierStepCount" sourceName="iPhone" sourceVersion="9.0.2" device="<<HKDevice: 0x128f211b0>, name:iPhone, manufacturer:Apple, model:iPhone, hardware:iPhone6,2, software:9.0.2>" unit="count" creationDate="2015-10-15 11:08:41 +0200" startDate="2015-10-15 10:00:29 +0200" endDate="2015-10-15 10:05:31 +0200" value="227"/>
[..]

And here is an example of the Fitbit CSV format:

Body
Date,Weight,BMI,Fat
"01-01-2019","70.1","0","0"
"02-01-2019","70.1","0","0"
"03-01-2019","70.1","0","0"
[..]

Activities
Date,Calories Burned,Steps,Distance,Floors,Minutes Sedentary,Minutes Lightly Active,Minutes Fairly Active,Minutes Very Active,Activity Calories
"01-01-2019","0","11","0.01","0","0","0","0","0","0"
"02-01-2019","0","13,666","10.4","0","0","0","0","0","0"
"03-01-2019","0","6,901","5.78","0","0","0","0","0","0"
[..]

Seems straight-forward. To get the data from one format to the other, I wrote a little Python script to convert the data:

https://github.com/simonkrenger/apple-health-to-fitbit

So in order to import your Apple Health data to Garmin Connect, follow these steps:

  • Export your Apple Health data (in the app, click the icon in the top right, select “Export Health Data”)
  • Download the script above and place the two files in the ZIP in the same folder as the script.
  • Run the script to generate a CSV

You can find example output in the repository above. Import the generated CSV file using the “Import” functionality of Garmin Connect.

Note that my script converts all the data in the XML files. Unfortunately, Garmin Connect only allows import of data year-by-year, so you might need to manually split your CSV files. If you try to import more than one year (e.g. data from 2018 and from 2019), the import functionality will throw an error.

Hello world

My name is Simon Krenger, I am a Technical Account Manager (TAM) at Red Hat. I advise our customers in using Kubernetes, Containers, Linux and Open Source.

Elsewhere

  1. GitHub
  2. LinkedIn
  3. GitLab