fit
Read and write Garmin FIT (Flexible and Interoperable Data Transfer) files from Python.
FIT is a binary format designed for sport, fitness, and health devices. It is compact, interoperable, and extensible — any FIT-compliant device can interpret a FIT file from any other FIT-compliant device.
Installation
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
Or use the Makefile:
make install
Usage
Reading a FIT file
from fit import FitFile
with FitFile.open("path/to/activity.fit") as f:
for message in f:
print(message)
Copying a FIT file
from fit import FitFile
with FitFile.open("path/to/source.fit") as src:
with FitFile.open("path/to/copy.fit", mode="w") as dst:
dst.copy(src)
Creating a new FIT file
from fit.files.activity import ActivityFile
from fit.messages.common import FileCreator
fnew = ActivityFile.create("path/to/new.fit")
fnew.append(FileCreator(software_version=100))
fnew.write()
fnew.close()
Reading from a stream
from io import BytesIO
from fit import FitFile
data = open("path/to/activity.fit", "rb").read()
with FitFile.open(BytesIO(data)) as f:
for message in f:
print(message)
Development
make install # create .venv and install all dev dependencies
make format # run black
make lint # run ruff
make typecheck # run mypy
make test # run pytest with coverage
make tox # run tests across Python 3.9, 3.10, 3.12
make clean # remove build artefacts and the virtualenv
License
BSD 3-Clause — see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fit-0.5.1.tar.gz
(46.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
fit-0.5.1-py3-none-any.whl
(53.1 kB
view details)
File details
Details for the file fit-0.5.1.tar.gz.
File metadata
- Download URL: fit-0.5.1.tar.gz
- Upload date:
- Size: 46.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52fe23e53ebd973418099114068893e57626c1d23d232eaf38a252cbef73e61a
|
|
| MD5 |
d4a8e930cec85ef5809770065832d8db
|
|
| BLAKE2b-256 |
061bb2cb459c54c2937723392be175fff5dd89d9fec0c2202a933c151ecce37b
|
File details
Details for the file fit-0.5.1-py3-none-any.whl.
File metadata
- Download URL: fit-0.5.1-py3-none-any.whl
- Upload date:
- Size: 53.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc45bd0455784ba6292b50386e71f46b840094b1d6286bb6df987eadeb06c556
|
|
| MD5 |
119c7817c93d21922c71bde79f73e91a
|
|
| BLAKE2b-256 |
e77aeead630b0ec75a0fea676f18e597ee2ee0881f1e8e93c85be6e877bb569f
|