Skip to content
Browse files

Another attempt at fixing #8

At least all points left will count towards the last lap.
  • Loading branch information...
1 parent 03e55e0 commit 0f6d3d29cdea51310a93c6ce89f9b6b8bd2b3cfc @mlt committed Jun 24, 2012
Showing with 6 additions and 3 deletions.
  1. +5 −2 src/csv2tcx.py
  2. +1 −1 src/download.py
View
7 src/csv2tcx.py
@@ -1,6 +1,7 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# This script converts lap and point data into TCX history
+from __future__ import print_function
import argparse, os
from csv import DictReader
from pytz import timezone, utc
@@ -25,6 +26,7 @@
track_start = tz.localize(datetime.strptime(track["Start"], "%Y-%m-%d %H:%M:%S"))
except: # support for legacy format with standalone x1
track_start = tz.localize(datetime.strptime("{:s}:{:s}".format(track["Start"], track["x1"]), "%Y-%m-%d %H:%M:%S"))
+ laps_left = int(track["Laps"])
# e = datetime.strptime(track["End"], "%Y-%m-%d %H:%M").replace(tzinfo=tz)
print("""<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
@@ -45,6 +47,7 @@
points = DictReader(p)
thePoint = next(points)
for theLap in laps:
+ laps_left -= 1
time = float(theLap["Time"])
kcal = int(float(theLap["kcal"]))
lap_dist = float(theLap["Distance"])*1.e3
@@ -82,7 +85,7 @@
# print("Point {:s} Over the lap {:s} by distance".format(thePoint["No"], theLap["Lap"]))
lap_start = time
break
- if time > lap_start and not int(theLap["autolap"]):
+ if time > lap_start and not int(theLap["autolap"]) and laps_left:
# print("Point {:s} {:s} Over the lap {:s} {:s} by time".format(thePoint["No"], time.isoformat(), theLap["Lap"], lap_start.isoformat()))
lap_start = time
break
View
2 src/download.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3.2
+#!/usr/bin/env python
from __future__ import print_function
import sys,os
import subprocess,stat,tempfile

0 comments on commit 0f6d3d2

Please sign in to comment.
Something went wrong with that request. Please try again.