Coder Social home page Coder Social logo

fitdecode's Introduction

fitdecode

Latest Docs

A FIT file parsing and decoding library written in Python3 (>= 3.6).

Usage Example

Read a FIT file, frame by frame:

import fitdecode

with fitdecode.FitReader('file.fit') as fit:
    for frame in fit:
        # The yielded frame object is of one of the following types:
        # * fitdecode.FitHeader (FIT_FRAME_HEADER)
        # * fitdecode.FitDefinitionMessage (FIT_FRAME_DEFINITION)
        # * fitdecode.FitDataMessage (FIT_FRAME_DATA)
        # * fitdecode.FitCRC (FIT_FRAME_CRC)

        if frame.frame_type == fitdecode.FIT_FRAME_DATA:
            # Here, frame is a FitDataMessage object.
            # A FitDataMessage object contains decoded values that
            # are directly usable in your script logic.
            print(frame.name)

Command line utilities

fitjson exports JSON:

$ fitjson --pretty -o out_file.json in_file.fit

To ease the introspection or your FIT files, fittxt exports to a dedicated TXT format:

$ fittxt -o out_file.txt in_file.fit

Both commands accept a --filter option (or -f) which can be specified multiples times:

$ # include only RECORD messages:
$ fitjson -f=record -o out_file.json in_file.fit

$ # exclude FILE_ID and EVENT messages:
$ fitjson -f=-file_id -f=-event -o out_file.json in_file.fit

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 [email protected]: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's API is not compatible with fitparse's
  • 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 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 either matched, or only computed, or just 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

Documentation is available at https://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.

fitdecode's People

Contributors

polyvertex avatar hugokernel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.