Skip to content

Make file reading more robust #30

@charlieforward9

Description

@charlieforward9

Fit files seem to have an issue every now and then... I am using the dependent library https://github.com/dodo-saba/fit2gpx

Traceback (most recent call last):
  File "/Users/crich/development/github/NEW_HEAT/strava_parser.py", line 127, in <module>
    strava_conv.strava_fit_to_gpx()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/fit2gpx.py", line 349, in strava_fit_to_gpx
    df_laps, df_points = self.fit_to_dataframes(self._dir_activities + f_activity)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/fit2gpx.py", line 110, in fit_to_dataframes
    for frame in fit_file:
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/fitdecode/reader.py", line 232, in __iter__
    yield from self._read_next()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/fitdecode/reader.py", line 351, in _read_next
    self._read_header()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/fitdecode/reader.py", line 424, in _read_header
    raise FitHeaderError(f'not a FIT file @ {self._chunk_offset}')
fitdecode.exceptions.FitHeaderError: not a FIT file @ 0

I tried putting the fit file into FitFileViewer as well, and got an error. However, when I try to convert the fit file to gpx with GoToes, it works without any problem.

It would be nice to have a handler that reads the fit file using the same type of error handling as gotoes, such that it does not crash the parsing.

Problematic File:
9702592680.fit.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions