Skip to main content

FIT file parser and decoder

Project description

fitdecode

Latest Docs https://travis-ci.org/polyvertex/fitdecode.svg

A FIT file parsing and decoding library written in Python3 (3.6+ only).

Usage Example

Read a FIT file, frame by frame:

import fitdecode

with fitdecode.FitReader(src_file) as fit:
    for frame in fit:
        # The yielded *frame* object is of one of the following types:
        # * fitdecode.FitHeader
        # * fitdecode.FitDefinitionMessage
        # * fitdecode.FitDataMessage
        # * fitdecode.FitCRC
        #
        # A fitdecode.FitDataMessage object contains decoded values that are
        # directly usable in your script logic.
        pass

Installation

fitdecode is available on PyPI:

$ pip install fitdecode

Or, to get the latest working version, you can clone fitdecode’s source code repository before installing it:

$ git clone git@github.com:polyvertex/fitdecode.git
$ cd fitdecode
$ python setup.py test     # optional step to run unit tests
$ python setup.py install

Note that for convenience, the cmd directory located at the root of the source code tree can safely be added to your PATH, so that fitdecode commands can be called without the package to be installed.

Overview

fitdecode is a non offensive and incompatible rewrite of the fitparse library, with some improvements and additional features, as well as efforts made to optimize both speed and memory usage.

Main differences between fitdecode and fitparse:

  • fitdecode requires Python version 3.6 or greater

  • fitdecode allows concurrent reading of multiple files by being thread-safe, in the sense that fitdecode’s objects keep their state stored locally

  • fitdecode high-level interfaces are not compatible with fitparse’s FitFile

  • fitdecode does not discard the FIT header and the CRC footer while iterating a file, which allow to get a complete 1:1 representation of the file that is being read

  • This also allows the client to easily deal with so-called chained FIT files, as per FIT SDK definition (i.e. concatenated FIT files)

  • fitdecode offers optional access to records, headers and footers in their binary form, to allow FIT file cutting, stitching and filtering at binary level

Why a new library?

A new library has been created instead of just offering to patch fitparse because many changes and adds in fitdecode break fitparse’s backward compatibilty and because it allowed more freedom during the development of fitdecode.

Documentation

Documentation is available at http://fitdecode.readthedocs.io/

License

This project is distributed under the terms of the MIT license. See the LICENSE.txt file for details.

Credits

fitdecode is largely based on the generic approach adopted by fitparse to define FIT types and to decode raw values. That includes the module profile.py and all the classes it refers to, as well as the script generate_profile.py.

Change Log

v0.3.0 (2018-07-27)

  • Added fitdecode.utils.get_mesg_field

  • Added fitdecode.utils.get_mesg_field_num

  • Minor improvements and corrections

v0.2.0 (2018-07-16)

  • Added FieldData.name_or_num

  • Added FitDataMessage.get_fields

  • Added FitDataMessage.get_values

  • Improved FitDataMessage.get_field (idx arg)

  • Improved FitDataMessage.get_value (idx arg)

  • Completed documentation of FitDataMessage

  • Improved documentation of FieldData

  • FitReader’s internal state is reset as well after a FitCRC has been yielded (i.e. not only when a FIT header is about to be read), in order to avoid incorrect behavior due to malformed FIT stream

v0.1.0 (2018-07-14)

  • Added class property frame_type (read-only) to FitHeader, FitCRC, FitDefinitionMessage and FitDataMessage (records module) to ease and speed up type checking

  • Added FitDataMessage.get_value method

  • string values with no null byte are still decoded (in full length)

  • cmd directory added to the source code tree for convenience

v0.0.1 (2018-07-08)

  • First release

v0.0.0 (2018-05-31)

  • Birth!

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

fitdecode-0.3.0.tar.gz (74.4 kB view details)

Uploaded Source

Built Distribution

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

fitdecode-0.3.0-py3-none-any.whl (83.7 kB view details)

Uploaded Python 3

File details

Details for the file fitdecode-0.3.0.tar.gz.

File metadata

  • Download URL: fitdecode-0.3.0.tar.gz
  • Upload date:
  • Size: 74.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.9 CPython/3.6.5

File hashes

Hashes for fitdecode-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0ee96fc7d8224851df7cf27f75fafdb3f6c93b62a318c5a29160f6052fd4c622
MD5 51130765db91007f0bbfd1c12806bcb8
BLAKE2b-256 95fb218fb76f8c7269bbb8f9ad70e4e254de9b81258d73b9630e0a729ba960fe

See more details on using hashes here.

File details

Details for the file fitdecode-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: fitdecode-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 83.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.9 CPython/3.6.5

File hashes

Hashes for fitdecode-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 481bf5c26b22cd7a89987a941cc67bb0a43eeb733f41993573cd7925dc14080b
MD5 8d7b8e2a554ed99926661c47551a7dc1
BLAKE2b-256 65cd03bd62982da283bbf8fd88d438784cb213b59eba610e3ae45510e2211de9

See more details on using hashes here.

Supported by

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