Skip to content

Commit

Permalink
Another attempt at fixing #8
Browse files Browse the repository at this point in the history
At least all points left will count towards the last lap.
  • Loading branch information
mlt committed Jun 24, 2012
1 parent 03e55e0 commit 0f6d3d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions 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
Expand All @@ -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" ?>
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down

0 comments on commit 0f6d3d2

Please sign in to comment.