Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env python
# Convert a TCX file exported from strava's export data:
# to a TCX file ready to upload to
# This is based on the logic from
# but I just find it more convenient to:
# ~/ < strava_activity.tcx > garmin_activity.tcx
# or
# cat strava_activity.tcx | ~/ > garmin_activity.tcx
import re
import sys
substitutions = [
('<Creator><Name>PELOTON</Name></Creator>', ''),
('\.\d+</Watts>', '</Watts>'),
('\.\d+</Calories>', '</Calories>'),
('\.\d+</Cadence>', '</Cadence>'),
('\.\d+</Value></AverageHeartRateBpm>', '</Value></AverageHeartRateBpm>'),
('\.\d+</Value></MaximumHeartRateBpm>', '</Value></MaximumHeartRateBpm>'),
('\.\d+</Value><HeartRateBpm>', '</Value></HeartRateBpm>'),
('\.0\<\/', '</'),
def main():
c =
for orig, replacement in substitutions:
c = re.sub(orig, replacement, c, flags=re.IGNORECASE )
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.