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. Fields are None when the source format/file doesn't record them. Values come from the file's own summary fields, never computed/derived from records or laps.

Field Unit FIT TCX GPX
sport Yes Yes
start_time Yes Yes Yes (*)
total_elapsed_time seconds Yes
total_distance km Yes
total_calories kcal Yes
avg_heart_rate, max_heart_rate bpm Yes
avg_speed, max_speed km/h Yes
creator Yes Yes Yes
notes Yes Yes

(*) GPX's start_time comes from metadata/time, which is technically the file's export time rather than the activity's start.

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.

Download files

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

Source Distribution

activity_parser-0.11.0.tar.gz (42.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

activity_parser-0.11.0-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file activity_parser-0.11.0.tar.gz.

File metadata

  • Download URL: activity_parser-0.11.0.tar.gz
  • Upload date:
  • Size: 42.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for activity_parser-0.11.0.tar.gz
Algorithm Hash digest
SHA256 4c6ea3bfcc39a20a3403436c6f901b9c6ab7f5ab04c9575dda88f4d09f4e3949
MD5 8c2aa9f4cdc0abaa1a090633202c193c
BLAKE2b-256 7b36a6e9978673f4188f0530f38c9004c2a3cc48bd960c38b05fdd34e2d9a77c

See more details on using hashes here.

Provenance

The following attestation bundles were made for activity_parser-0.11.0.tar.gz:

Publisher: release.yml on tabishm52/activity_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file activity_parser-0.11.0-py3-none-any.whl.

File metadata

File hashes

Hashes for activity_parser-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8923b454118b63f534d111d59e56846560b493e94c9c037717685a70ea7eafbe
MD5 03d4011ebf09ecf799c4859928eab6f5
BLAKE2b-256 3bbd611c7887ad29047704323a52305190e0a2046ea4c51dd9016d19615bf6d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for activity_parser-0.11.0-py3-none-any.whl:

Publisher: release.yml on tabishm52/activity_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.12.0

2 files

This release

0.11.0 This release

2 files

0.10.0

2 files

0.9.0

2 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