From 5ada658c03fbac223fb0300f0768044d3c244070 Mon Sep 17 00:00:00 2001 From: Adam Neumann Date: Sun, 29 May 2016 11:52:24 -0600 Subject: [PATCH] Extract time stamp of data points --- README.md | 1 + tcxparser.py | 3 +++ test_tcxparser.py | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/README.md b/README.md index c77e0ed..02f4e48 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Data extracted: - average altitude during workout - ascent and descent of workout - max and min altitude + - time stamp of each data point (in ISO UTC) ## Installation diff --git a/tcxparser.py b/tcxparser.py index 3f7f6cd..c7e5d09 100644 --- a/tcxparser.py +++ b/tcxparser.py @@ -19,6 +19,9 @@ def hr_values(self): def altitude_points(self): return [float(x.text) for x in self.root.xpath('//ns:AltitudeMeters', namespaces={'ns': namespace})] + def time_values(self): + return [x.text for x in self.root.xpath('//ns:Time', namespaces={'ns': namespace})] + @property def latitude(self): return self.activity.Lap.Track.Trackpoint.Position.LatitudeDegrees.pyval diff --git a/test_tcxparser.py b/test_tcxparser.py index bfe0a23..0d354df 100644 --- a/test_tcxparser.py +++ b/test_tcxparser.py @@ -16,6 +16,10 @@ def test_altitude_points_are_correct(self): self.assertEquals(self.tcx.altitude_points()[0], 178.942626953) self.assertEquals(self.tcx.altitude_points()[-1], 166.4453125) + def test_time_values_are_correct(self): + self.assertEquals(self.tcx.time_values()[0], '2012-12-26T21:29:53Z') + self.assertEquals(self.tcx.time_values()[-1], '2012-12-26T22:03:05Z') + def test_latitude_is_correct(self): self.assertEquals(self.tcx.latitude, 35.951880198)