Skip to main content

Simple parser for Garmin TCX files

Project description

Requirement Updates Fedora package

python-tcxparser is a minimal parser for Garmin’s TCX file format. It is not in any way exhaustive.

Data extracted:
  • latitude & longitude of start point of workout

  • type of workout (running, walking, etc)

  • time of completion of workout (in ISO UTC)

  • distance of workout (in meters)

  • duration of workout (in seconds)

  • calories burned during workout (as estimated by device)

  • average, max and min heart rate during workout

  • average pace during workout

  • average altitude during workout

  • ascent and descent of workout

  • max and min altitude

  • time stamp of each data point (in ISO UTC)

  • average and max cadence (cycling activities)

  • percentage and time spent in heart rate zone

  • average and max power

  • total steps (also strokes)

Installation

Install it from PyPI:

pip install python-tcxparser

Usage

Basic usage example:

>>> import tcxparser
>>> tcx = tcxparser.TCXParser('/home/vinod/Downloads/20121226-212953.tcx')
>>> # Duration of workout in seconds
... tcx.duration
1992.78
>>> # latitude/longitude at start of workout
... tcx.latitude
35.951880198
>>> tcx.longitude
-79.0931872185
>>> tcx.activity_type
'running'
>>> # ISO UTC timestamp when workout completed
... tcx.completed_at
'2012-12-26T22:03:05Z'
>>> # distance of workout in meters
... tcx.distance
4686.31103516
>>> tcx.distance_units
'meters'
>>> # calories burned (as reported by device)
... tcx.calories
379
>>> # percentage of workout spent in each user-defined heart rate zone
... tcx.hr_percent_in_zones({"Z0": (0, 99), "Z1": (100, 129), "Z2": (130, 200)})
{"Z0": 14, "Z1": 36, "Z2": 50}

Compatibility

License

  • BSD

Maintainer Information

We use Github Actions to lint (using pre-commit, black, isort, and flake8), test (using tox and tox-gh-actions), and calculate coverage (using coverage).

We have a local script to do these actions locally, named maintain.sh:

$ ./maintain.sh

A Github Action workflow also builds and pushes a new package to PyPI whenever a new Release is created in Github. This uses a project-specific PyPI token, as described in the PyPI documentation here. That token has been saved in the PYPI_PASSWORD settings for this repo, but has not been saved anywhere else so if it is needed for any reason, the current one should be deleted and a new one generated.

As always, be sure to bump the version in setup.py before creating a Release, so that the proper version gets pushed to PyPI.

Contact

Please contact me with any questions: Vinod Kurup (vinod@kurup.com)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-tcxparser-2.3.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

python_tcxparser-2.3.0-py2.py3-none-any.whl (7.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file python-tcxparser-2.3.0.tar.gz.

File metadata

  • Download URL: python-tcxparser-2.3.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for python-tcxparser-2.3.0.tar.gz
Algorithm Hash digest
SHA256 b05f390f12c91e8ae78ec7c5eb0582f5fcd4e938bbfe6cb289158a2eec647105
MD5 b35d63f72777d75caa83f45de9ac0b1f
BLAKE2b-256 b51c53da9599ee920c19a93903a4852b66fb5174824573d11a611788825cf645

See more details on using hashes here.

File details

Details for the file python_tcxparser-2.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for python_tcxparser-2.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a223cc2c4f5e9e054cd68158008564e986eb7191247b55c254650bc8662451fd
MD5 83b7e4a385a586fc5763477c7304aefa
BLAKE2b-256 1ec43d78e89b672c6f16118d3da29afe8e9fe397184d5059358cb7fe850903eb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page