R: Read Garmin activity export summary to a dataframe

The Garmin export is a deeply nested JSON structure. It only appears to fill in columns where there is data. Like so:

    "summarizedActivitiesExport": [
        "activityId": 9342780544,
        "uuidMsb": -8608655323230679000,
        "uuidLsb": -8443901297724183000,
        "name": "Ambler Running",
        "activityType": "running",
        "userProfileId": 106383175,
        "timeZoneId": 149,
        "beginTimestamp": 1659703707000,
        "eventTypeId": 9,

The following code will read it to a dataframe:

df <- data.table::rbindlist(read_json(filename)[[1]]$summarizedActivitiesExport, fill=TRUE) 

activityId uuidMsb uuidLsb name activityType userProfileId timeZoneId beginTimestamp eventTypeId rule
1: 9342780544 -8.608655e+18 -8.443901e+18 Ambler Running running 106383175 149 1.659704e+12 9 private
2: 9311888059 -3.045696e+18 -8.601673e+18 Ambler Running running 106383175 149 1.659285e+12 9 private
3: 9305033616 5.784667e+17 -8.295883e+18 Ambler Walking walking 106383175 149 1.659202e+12 9 private
4: 9296749083 -6.688525e+17 -7.950984e+18 Ambler Running running 106383175 149 1.659094e+12 9 private

You’ll get an error like so, which seems to be ok:

Warning message:
In data.table::rbindlist(read_json(filename)[[1]]$summarizedActivitiesExport, :
Column 40 [‘summarizedDiveInfo’] of item 1 is length 0. This (and 8 others like it) has been filled with NA (NULL for list columns) to make each item uniform.

One Reply to “R: Read Garmin activity export summary to a dataframe”

  1. Hello Gary,
    I have my summaryActivitiesExport.json file and I’ve been struggling to figure out how to read the data. I’m a Python beginner and although I’ve tried asking AI, I get a lot of errors and it isn’t working. Could you share a script to do it? Thank you!! 🙏🏻 (so far, what I’ve got is all the data in a row and 39077 columns… so sad.)

Leave a Reply

Your email address will not be published. Required fields are marked *