alenrajsp / tcxreader

tcxreader is a reader / parser for Garmin’s TCX file format. It also works well with missing data!
MIT License
21 stars 10 forks source link

Read error with missing HR data values #47

Closed simonpickering closed 9 months ago

simonpickering commented 9 months ago

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.

alenrajsp commented 9 months ago

I am solving the issue and will provide an update soon. This will be today/tommorow in the new version.

alenrajsp commented 9 months ago

@simonpickering can you please provide also example TCX file so I can test it before new version release.

simonpickering commented 9 months ago

I don't have anything particularly small/anonymised to hand I'm afraid. I'm happy to test for you though, or I expect you can generate the same behaviour by editing a working TCX to create an empty HeartRateBpm value.

Let me know if I can help, thanks for looking at it so swiftly.

alenrajsp commented 9 months ago

@all-contributors please add @simonpickering for bug reports.

allcontributors[bot] commented 9 months ago

@alenrajsp

I've put up a pull request to add @simonpickering! :tada:

alenrajsp commented 9 months ago

@simonpickering please check the new release 0.4.9 which should solve all your issues. Also please check the updated readme section regarding missing data handling. Closing for now.