Skip to content

Instantly share code, notes, and snippets.

@cast42
Last active August 29, 2015 13:55
Show Gist options
  • Save cast42/8729445 to your computer and use it in GitHub Desktop.
Save cast42/8729445 to your computer and use it in GitHub Desktop.
Adding virtual power to TCX file
import re
with open('29-01-14 20-53-27.tcx', 'rt') as f:
for line in f:
print line,
match = re.match('\s+<Speed>(\d+.\d+)',line)
if match:
speed = float(match.group(1))
speed_in_kmperh = speed/1000.0*60.0*60.0
power_in_watt = int(speed_in_kmperh/6.0*50.0)
print ' <Watts>%d</Watts>' % power_in_watt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment