Skip to main content

Garmin TCX and GPX file readers for running activities.

Project description

activereader

Python library for reading Garmin TCX and GPX running activity files.

License

Example

activereader provides the Tcx and Gpx file reader classes.

TCX and GPX files can be exported from Garmin Connect.

Use Tcx to read and access data from a TCX file:

import pandas as pd

from activereader import Tcx

reader = Tcx.from_file('tests/testdata.tcx')

# Build a DataFrame using only trackpoints (as records).
initial_time = reader.activity_start_time
records = [
  {
    'time': int((tp.time - initial_time).total_seconds()),
    'lat': tp.lat,
    'lon': tp.lon,
    'distance': tp.distance_m,
    'elevation': tp.altitude_m,
    'heart_rate': tp.hr,
    'speed': tp.speed_ms,
    'cadence': tp.cadence_rpm,
  } for tp in reader.trackpoints
]

df = pd.DataFrame.from_records(records)

Background

This project originated as the file-reading part of my heartandsole package. Lately, I've been interested in keeping my work in more self-contained modules with lighter dependencies, so I split it out.

The idea is to provide a simple API for accessing data from Garmin files, similar to the way python-fitparse provides access to Garmin's impenetrable .fit files. I don't aim to do everything, though; I want to just focus on activity files that represent runs (and maybe walks/hikes) for now. When I try to cover all cases, the schemas and profiles quickly grow out of control. Garmin seems to have a reputation for making their files indecipherable, and I like solving puzzles, so I will focus on translating Garmin's language into human language. This is in opposition to waiting for Garmin to document all the features of all its files.

Tangent time: when I was working on picking apart Garmin's.fit file structure with my own device's files, there were a number of undocumented, indecipherable fields. Add to that, Garmin does not seem to keep documentation online for its older .fit SDKs, so if your device uses an older one, you might just be out of luck trying to decipher it. I would rather keep my own separate source of truth, than count on Garmin's being forthcoming with info.

Dependencies and Installation

lxml and python-dateutil are required.

The package is available on PyPi and can be installed with pip:

$ pip install activereader

License

License

This project is licensed under the MIT License. See LICENSE file for details.

Project Status

The project has reached a stable point and I don't expect to be changing much for now - future versions will likely build on what's here. But sometimes I change my mind and tear everything apart, so who knows. This package will remain focused on extracting data from GPX and TCX files...of that I feel sure.

Complete

  • Develop capability to read running tcx and gpx files.

Current Activities

  • Handle pauses and laps in files (things I avoid in my own workouts because they complicate and obscure the DATA!). The body keeps the score, but the watch keeps the stats.

Future Work

  • Expand capability to read running activity files

    • .pwx (is this Garmin?)
  • Make a project wiki so I can be as verbose as I please. (You mean this isn't you being verbose?)

Contact

Reach out to me at one of the following places!

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

activereader-0.0.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

activereader-0.0.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file activereader-0.0.1.tar.gz.

File metadata

  • Download URL: activereader-0.0.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.5

File hashes

Hashes for activereader-0.0.1.tar.gz
Algorithm Hash digest
SHA256 2615106c9e9760c153f27074017e137b1900a3cacb68342e1954513b3f3256e0
MD5 4d8a5de2e6058426193018210c2e51f0
BLAKE2b-256 43dfa3dcbe2c81db3bfe83eae3fe648bb5e76fcb5607d98c749c09a8694b63cb

See more details on using hashes here.

File details

Details for the file activereader-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: activereader-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.5

File hashes

Hashes for activereader-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d68112f1aac436b68574f094c507761a2da20cf680ea81440b532de51b761ed6
MD5 9a9cf0fdacc098fb8227341c21718150
BLAKE2b-256 f6d858f526520c20aa65cab5f194a2f3f5e13b50916f438b8a904e999b4f79dc

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