FIT file parser and decoder
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 if isinstance(frame, fitdecode.FitDataMessage): # Here, frame is a FitDataMessage object. # A FitDataMessage object contains decoded values that # are directly usable in your script logic. print(frame.name)
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 firstname.lastname@example.org: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.
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 is faster
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 interface - FitReader - is 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)
CRC computation and matching are both optional. CRC can be matched, only computed, or fully ignored for faster reading.
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 is available at http://fitdecode.readthedocs.io/
This project is distributed under the terms of the MIT license. See the LICENSE.txt file for details.
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.
Added FitReader.last_timestamp property
Fixed: FitReader was raising KeyError instead of FitParseError when a dev_type was not found
FitParseError message contains more details upon malformed file in some cases
FIT SDK profile upgraded to v21.16
README’s usage example slightly improved
Added fitdecode.DataProcessorBase class
check_crc - the parameter to fitdecode.FitReader’s constructor - can now be either “enabled”, “read-only” or “disabled” (fix #1)
Minor speed improvements
fitdecode.FitDataMessage.get_fields is now a generator
fitdecode.FitDataMessage.get_values is now a generator
fitdecode.DefaultDataProcessor now converts hr.event_timestamp values that were populated from hr.event_timestamp_12 components to datetime.datetime objects for convenience
fitjson and fittxt utilities: * Added support for input files with Unicode characters * Still write output file even if an error occurred while parsing FIT file
Fixed handling of some FIT fields that are both scaled and components. See https://github.com/dtcooper/python-fitparse/issues/84
Improved support for malformed FIT files. See https://github.com/dtcooper/python-fitparse/issues/62
generate_profile utility slightly improved
Added some unit tests
Minor improvements and corrections
Minor improvements and corrections
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
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
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for fitdecode-0.6.0-py3-none-any.whl