dtcooper / python-fitparse

Python library to parse ANT/Garmin .FIT files
http://pythonhosted.org/fitparse/
MIT License
738 stars 184 forks source link
ant fit fit-sdk fitparse garmin python-fitparse

python-fitparse

:warning: NOTE: I have limited to no time to work on this package these days!

I am looking for a maintainer to help with issues and updating/releasing the package. Please reach out via email at david@dtcooper.com if you have interest in helping.

If you're having trouble using this package for whatever reason, might we suggest using an alternative library: fitdecode by polyvertex.

Cheers,

David

Here's a Python library to parse ANT/Garmin .FIT files. Build Status

Install from PyPI:

pip install fitparse

FIT files

Usage

A simple example of printing records from a fit file:

import fitparse

# Load the FIT file
fitfile = fitparse.FitFile("my_activity.fit")

# Iterate over all messages of type "record"
# (other types include "device_info", "file_creator", "event", etc)
for record in fitfile.get_messages("record"):

    # Records can contain multiple pieces of data (ex: timestamp, latitude, longitude, etc)
    for data in record:

        # Print the name and value of the data (and the units if it has any)
        if data.units:
            print(" * {}: {} ({})".format(data.name, data.value, data.units))
        else:
            print(" * {}: {}".format(data.name, data.value))

    print("---")

The library also provides a fitdump script for command line usage:

$ fitdump --help
usage: fitdump [-h] [-v] [-o OUTPUT] [-t {readable,json}] [-n NAME] [--ignore-crc] FITFILE

Dump .FIT files to various formats

positional arguments:
  FITFILE               Input .FIT file (Use - for stdin)

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose
  -o OUTPUT, --output OUTPUT
                        File to output data into (defaults to stdout)
  -t {readable,json}, --type {readable,json}
                        File type to output. (DEFAULT: readable)
  -n NAME, --name NAME  Message name (or number) to filter
  --ignore-crc          Some devices can write invalid crc's, ignore these.

See the documentation for more: http://dtcooper.github.io/python-fitparse

Major Changes From Original Version

After a few years of laying dormant we are back to active development! The old version is archived as v1-archive.

Updating to new FIT SDK versions

License

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