alenrajsp / tcxreader Goto Github PK
View Code? Open in Web Editor NEWtcxreader is a reader / parser for Garmin’s TCX file format. It also works well with missing data!
License: MIT License
tcxreader is a reader / parser for Garmin’s TCX file format. It also works well with missing data!
License: MIT License
Please add a changelog file for more accessible tracking of changes.
@alenrajsp, one similar example is already in the examples folder.
Will comment bot to add contributors for this project.
@alenrajsp, pytest is failing due to the assertion errors. Please check it out!
def test_hr_max(self):
self.assertEqual(self.tcx.hr_max, None) -> it should be 200
There is another None:
def altitude_avg(self):
self.assertEqual(self.tcx.altitude_avg, None)
Similar issue to #19 - if the TCX file contains Cadence as a float value, e.g. '86.0' it will cause "ValueError: invalid literal for int() with base 10: '0.0'". If helpful, I've attached a truncated TCX file exported from a Peloton bike which has the issue, saved as .txt to allow Github import.
Code on line
tcxreader/tcxreader/tcxreader.py
Line 146 in 9d0f07e
@alenrajsp, "about" section may be wrong.
tcxparser is a reader / parser for Garmin’s TCX file format. It also works well with missing data!
You may change tcxparser to tcxreader.
FYI, in trying to read some tcx files from Google fit I had to change several locations where it tried to cast to int to:
int(float(textalue))
because the file had things like HeartRate as 86.0. Without that you get this error:
https://stackoverflow.com/questions/1841565/valueerror-invalid-literal-for-int-with-base-10
Ex: line 130 of tcxreader:
tcx_point.hr_value = int(float(heart_rate.text))
@alenrajsp, use your imagination 👍
Return number of laps of an activity
Hi,
I'm using the tcxreader in a personal project, and it works nicely with most of my tcx-files exported from Garmin. However for this one file where positional data of the trackpoints is missing (but timestamps, heartrate data etc. still available) it only reads out very little general information (author, activity_type), but tcx.trackpoints is a completely empty list. I am assuming there's an exception built in during the parsing of the file if no positional data is available? Would it be feasible/desirable to change that, so that all available data is read in and stored, even if some parameters are missing?
I have attached the relevant tcx-file for reference:
activity_12702654569.tcx.txt
Cheers, Paul
Using a file that was recorded during UK daylight savings time, the datetime for the trackpoints includes +01:00
, and trying to use such a file in the TCXReader produces the following ValueError:
ValueError: time data '2022-10-25T19:33:35.000+01:00' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'
This does not appear fixable on my end just by removing characters from each datetime in Python, as the error is related to the tcxReader.read()
function
If there is missing HR data in a TCX file, the read code is crashing for me with the following error:
...\lib\site-packages\tcxreader\tcxreader.py", line 144, in trackpoint_parser
tcx_point.hr_value = int(float(heart_rate.text))
TypeError: float() argument must be a string or a number, not 'NoneType'
Looking inside the TCX there are some missing values:
...
<HeartRateBpm>
<Value></Value>
</HeartRateBpm>
...
I guess this may also apply to other datafields too if the sensor falls out during a ride.
I'm using Python 3.9 (I know, a bit behind the times, but embedded platform) and tcxreader-0.4.6 via pip3.
./tests/test_tcxreader.py:4:1: W391 blank line at end of file
./examples/reader_demo.py:4:1: F401 'tcxreader.tcxreader.TCXTrackPoint' imported but unused
./examples/reader_demo.py:18:1: W191 indentation contains tabs
./examples/reader_demo.py:18:2: E101 indentation contains mixed spaces and tabs
./examples/reader_demo.py:19:1: W191 indentation contains tabs
./examples/reader_demo.py:19:2: E101 indentation contains mixed spaces and tabs
./examples/reader_demo.py:20:1: W191 indentation contains tabs
./examples/reader_demo.py:20:2: E101 indentation contains mixed spaces and tabs
./examples/reader_demo.py:21:1: W191 indentation contains tabs
./examples/reader_demo.py:21:2: E101 indentation contains mixed spaces and tabs
./examples/reader_demo.py:22:1: W191 indentation contains tabs
./examples/reader_demo.py:22:2: E101 indentation contains mixed spaces and tabs
./examples/reader_demo.py:23:1: W191 indentation contains tabs
./examples/reader_demo.py:23:2: E101 indentation contains mixed spaces and tabs
./examples/reader_demo.py:24:1: W191 indentation contains tabs
./examples/reader_demo.py:24:2: E101 indentation contains mixed spaces and tabs
./examples/reader_demo.py:25:1: W191 indentation contains tabs
./examples/reader_demo.py:25:2: E101 indentation contains mixed spaces and tabs
./examples/reader_demo.py:26:1: W191 indentation contains tabs
./examples/reader_demo.py:26:2: E101 indentation contains mixed spaces and tabs
./tcxreader/tcxreader.py:1:1: F401 'os' imported but unused
./tcxreader/tcxreader.py:6:1: F401 'pathlib.Path' imported but unused
./tcxreader/tcxreader.py:16:5: C901 'TCXReader.read' is too complex (34)
./tcxreader/tcxreader.py:73:21: E712 comparison to True should be 'if cond is True:' or 'if cond:'
./tcxreader/tcxreader.py:87:5: C901 'TCXReader.__find_hi_lo_avg' is too complex (14)
./tcxreader/tcxreader.py:93:36: E711 comparison to None should be 'if cond is not None:'
./tcxreader/tcxreader.py:95:37: E711 comparison to None should be 'if cond is not None:'
./tcxreader/tcxreader.py:97:35: E711 comparison to None should be 'if cond is not None:'
./tcxreader/tests/test_reader.py:3:1: F401 'tcxreader.tcxreader.TCXTrackPoint' imported but unused
./tcxreader/tests/test_reader.py:3:1: F401 'tcxreader.tcxreader.TCXExercise' imported but unused
./tcxreader/tests/conftest.py:3:1: E302 expected 2 blank lines, found 1
2 C901 'TCXReader.read' is too complex (34)
9 E101 indentation contains mixed spaces and tabs
1 E302 expected 2 blank lines, found 1
3 E711 comparison to None should be 'if cond is not None:'
1 E712 comparison to True should be 'if cond is True:' or 'if cond:'
5 F401 'tcxreader.tcxreader.TCXTrackPoint' imported but unused
9 W191 indentation contains tabs
1 W391 blank line at end of file
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.