Hi all,

A few weeks back, I wrote a blog on how to manually extract your strava data, create the csv version of your gpx file and then be able to plot that map in Tableau.

Well this week we will take one small part of that process and make it quicker easier through code.

As a brief reminder. To download the data you will need to navigate to “My Account”

Click to Get started on download your stats. Once you go to download them it will send you a link to your email associated with the account

Within the activities.csv you will see an associated gpx file. These files are essentially the mappings for our different activities.

The only problem we had was… Tableau doesn’t allow for gpx files, so we need to convert them into records of data.

Now if you don’t want to use python then by all means visit my previous blog, or navigate to GPS Visualiser website.

But this blog is all about how to more easily do this through code.

Lets take my previous gpx file from when I ran the Paris Half back in March. You will find it in the Github repository at the top of the page. (8663587823.gpx)

Open up a python IDE of your choice in my case I’m using pycharm.

Go to your terminal and add

pip install -U gpx-converter

Next thing, add the gpx file to your repository area.

All we need to do is update our code with the correct input file name and output file name and we are ready to hit run. For me, I’ve left them as the original strava activity numbers from my Strava page.

When we click run, you will see the csv version appear. Let’s go to Tableau to see if it has worked.

Looks pretty spot on. Do note, we need Time on path for Tableau to know in which order to draw the path for our longitude and latitude points.

Fantastic, this way we have completely eliminated the need for using an online converter!

Now this is okay but it only works for one gpx file at a time. So really we will need to create the equivalent for each of our files.


This next bit of code of course you can go away and amend.

I’ve written it so that we get a csv for each of our gpx files, if you only want one final csv file perhaps you rewrite this code but I wanted individuals to have both available.

For this bit of the tutorial I will be gluing together 10 gpx files, courtesy of my good friend Tom Smith. Tom actually got me into running in the first place, and I managed to dig out a few of his 10K badges from back in 2021 (before he moved home) that inspired me to take it more seriously.

First step is put your gpx files into a folder, like above.

This code snippet will convert the gpx file to a dataframe and add a column with the name of the gpx file. It will then save these files down to a chosen location as csvs, In this example I save them to a folder I created called OutputFiles. This means you will have a csv for each activity.

The next bit of code looks to locate the output files and then glue them together. It’s save this final document down as All_Data.csv

You’ll see it appear in the folder.

We can finally sense check that our data is correct. We see that the number of rows adds up to those of our 12 files.

We can also throw it into Tableau to check that it works the way we intend. Here are some of those runs as overlays.

That should be everything needed in terms of automating the gpx part of the process.

If you get stuck I recommend checking out the documentation here

My plan down the line is to be able to build full automated workflows for Strava dashboards for those that join my online fitness club. You can join here.

Going further:

  • Chart all your different activities that have maps
  • Create the same automation with a coding language of your choice
  • Improve the performance of the python code

Healthy body, healthy mind.