Skip to main content

activity-parser

CI PyPI Python versions License

Parser for loading FIT, TCX and GPX activity files into Pandas DataFrames.

Provides a parser object for reading (optionally gzipped) FIT, TCX, and GPX activity files and converting them into Pandas DataFrames. During import, field names extracted from activity files are normalized into a canonical set of output column names with consistent units to allow for standardized downstream data processing.

Installation

pip install activity-parser

Usage

Create a new instance of the ActivityParser class to be reused for subsequent parsing of activity files:

import activity_parser

parser = activity_parser.ActivityParser()

Parse FIT, TCX and GPX files into normalized DataFrames:

from activity_parser import ParseError

try:
    records, laps, activity = parser.parse("path/to/fit_file.fit")
    records, laps, activity = parser.parse("path/to/gpx_file.gpx")
    records, laps, activity = parser.parse("path/to/tcx_file.tcx")
except ParseError as e:
    ...

Each file is assumed to contain a single activity. Multiple activities/tracks (chained FIT files, multi-activity TCX, multi-track GPX) have their records/laps merged into one set of results. In those cases, the returned Activity summary reflects only the first activity/session in the file.

parse() raises ParseError (FitError for FIT files, XmlError for TCX/GPX) when a file fails to parse. It raises ValueError for an unrecognized or ambiguous file type.

Output data

records and laps are each a DataFrame of normalized data, e.g.:

                           distance  speed  cadence  heart_rate
time
2026-01-05 08:00:00+00:00      0.00   36.0       80         100
2026-01-05 08:00:01+00:00      0.01   36.0       81         101

A few notes on column handling:

  • Column names and units are standardized across source formats for known field types.
  • Unknown fields are omitted by default; customize columns via record_columns, lap_columns, and include_all_columns on ActivityParser — see its docstring for details.
  • Not every column appears in every file: parse() only includes columns actually present.

Records

Not all fields are available in all source formats. Fields marked with (*) are exporter-dependent.

Column Unit FIT TCX GPX
latitude, longitude degrees Yes Yes Yes
altitude meters Yes Yes Yes
distance km Yes Yes (*)
speed km/h Yes (*) (*)
cadence rpm Yes Yes (*)
heart_rate bpm Yes Yes (*)
power watts Yes (*) (*)
left_balance, right_balance percent Yes — —
accumulated_power watts Yes — —
temperature °C Yes — (*)
water_temperature °C — — (*)
depth meters — — (*)
course, bearing degrees — — (*)

Laps

GPX files have no lap data, so laps is always an empty DataFrame for GPX. Fields marked with (*) are exporter-dependent.

Column Unit FIT TCX
start_time timestamp Yes Yes
total_elapsed_time seconds Yes Yes
total_timer_time seconds Yes —
start_position_lat, start_position_long degrees Yes —
end_position_lat, end_position_long degrees Yes —
total_distance km Yes Yes
total_ascent, total_descent meters Yes —
avg_vam m/s Yes —
avg_speed km/h Yes (*)
max_speed km/h Yes Yes
avg_cadence rpm Yes Yes
max_cadence rpm Yes (*)
total_strokes count Yes —
steps count — (*)
avg_heart_rate, max_heart_rate bpm Yes Yes
time_in_hr_zone seconds Yes —
avg_power, max_power watts Yes (*)
normalized_power watts Yes —
left_balance, right_balance percent Yes —
time_in_power_zone seconds Yes —
total_work joules Yes —
avg_temperature, max_temperature °C Yes —
total_calories kcal Yes Yes
total_fat_calories kcal Yes —

Activity

activity is an Activity dataclass instance: a small file-level summary.

Field Unit FIT TCX GPX
sport — Yes Yes [1] Yes [1]
start_time — Yes Yes Yes [2]
total_elapsed_time seconds Yes Yes Yes
total_timer_time seconds Yes — —
total_distance km Yes Yes Yes
total_ascent, total_descent m Yes — —
total_calories kcal Yes Yes —
avg_heart_rate, max_heart_rate bpm Yes Yes Yes
avg_power, max_power W Yes Yes Yes
avg_cadence, max_cadence rpm Yes Yes Yes
avg_speed, max_speed km/h Yes Yes [3] Yes [3]
creator — Yes Yes Yes
notes — — Yes Yes

Fields are None when the source format/file doesn't record them. Many TCX/GPX fields are computed from record and lap data since they are not provided as activity-level summary fields by the file format.

Notes:

  1. TCX/GPX sport is normalized onto FIT's sport vocabulary; an unrecognized value is passed through unchanged.
  2. GPX start_time comes from metadata/time, which is technically the file's export time rather than the activity's start.
  3. TCX/GPX avg_speed divides by elapsed time, whereas FIT divides by timer time.

Examples

examples/ has runnable scripts for processing a directory of activity files, built on a shared parse_directory() helper:

  • check_archive.py <directory> [--all-columns] — a health check, broken down by file type: parsing failures, record column coverage, and file creators.
  • summarize_archive.py <directory> — a per-sport summary rollup, displaying key metrics across the archive.

Parser notes

FIT files

FIT parsing wraps garmin-fit-sdk, Garmin's official SDK, which decodes against the public FIT SDK profile.

parse() transforms certain FIT fields beyond decoding:

  • Positions are converted to degrees, distances to km, and speeds to km/h. Vertical rates (avg_vam, vertical_speed, and similar) stay in m/s.
  • For fields with lower- and higher-precision versions, only the higher-precision value is returned, under the base field's name.
  • For fields with sub-integer precision in a separate field, the precision is added into the base field.
  • left_right_balance (a bit-packed field) is decoded into left_balance/right_balance.
  • heart_rate is merged with a higher-rate hr stream when the file has one. Records outside its coverage keep their own device value.

Messages/fields that can't be resolved against the FIT profile (e.g. proprietary extensions) are kept as raw values under unknown_<n> names. Developer fields are resolved to their file-embedded names and flattened into ordinary columns alongside built-in fields.

parse_fit and parse_fit_raw are the lower-level functions ActivityParser.parse() wraps for FIT files. parse_fit returns the same canonical (records, laps, activity) shape, but without column curation. parse_fit_raw returns every message type in the file as its own uncurated DataFrame, in FIT-native units (semicircles, meters, m/s).

TCX & GPX files

TCX and GPX files are parsed natively in this package using lxml. Recognized elements and attributes are mapped onto the same canonical column names as FIT, with the same unit conventions.

The parser supports the following schema versions and extensions:

Format Schema version Extensions
TCX v2 Garmin ActivityExtension v2
GPX 1.0 / 1.1 Garmin TrackPointExtension v1/v2, Cluetrust gpxdata

Unrecognized elements and attributes are exported as string columns named with their XML namespace in Clark notation.

parse_gpx and parse_tcx are the lower-level functions ActivityParser.parse() wraps for these formats. They return the same canonical (records, laps, activity) shape, but without column curation.

Metadata

Release files for activity-parser 0.12.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for activity-parser 0.12.1
File Size Uploaded
activity_parser-0.12.1.tar.gz 52.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for activity-parser 0.12.1
File Interpreter ABI Platform
activity_parser-0.12.1-py3-none-any.whl Python 3 none any Details

Total release size: 77.0 kB

Release files / activity_parser-0.12.1.tar.gz

Download URL activity_parser-0.12.1.tar.gz
Size 52.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8e11913314dfd736e63974537a08d9aac8e140b4373b3f738baa3423dc0f3729
BLAKE2b-256 checksum
How to use checksums
4b2f8035d7844759bf3479193a2170bfd44e8e115ac662da6146d8f3665a00d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release files / activity_parser-0.12.1-py3-none-any.whl

Download URL activity_parser-0.12.1-py3-none-any.whl
Size 24.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a34529ce2de4d2e643a281be5584810abd241abc41156c8e09091db50c813cda
BLAKE2b-256 checksum
How to use checksums
1cc9000a81f5712e825f64d33ccdbe7a5df7a32b6d7d182a2b08a0241bd7e208
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.12.1 This release

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page