question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't open FIT file

See original GitHub issue

Is that project still alive? I tried this below on a file from a forerunner

from fitparse import FitFile
fitfile = FitFile("76NE5832.FIT")

That result as

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/fitparse/base.py", line 38, in __init__
    self._parse_file_header()
  File "/usr/local/lib/python2.7/dist-packages/fitparse/base.py", line 123, in _parse_file_header
    self._read_and_assert_crc(allow_zero=True)
  File "/usr/local/lib/python2.7/dist-packages/fitparse/base.py", line 83, in _read_and_assert_crc
    crc_expected, crc_actual = self._crc, self._read_struct('H')
  File "/usr/local/lib/python2.7/dist-packages/fitparse/base.py", line 75, in _read_struct
    raise FitEOFError("Tried to read %d bytes from .FIT file but got %d" % (size, len(data)))
fitparse.utils.FitEOFError: Tried to read 2 bytes from .FIT file but got 0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
pR0Pscommented, Jul 1, 2017

I just tried parsing that file using the version at 5283af577d593bfb11bdc582c7d2df61b6ce3c40 and it worked fine. Are you using the latest version?

@dtcooper Maybe the PyPI version needs updating?

0reactions
pR0Pscommented, Jul 1, 2017

Oh wow, so this is definitely a bug and a really unexpected one at that. It’s due to a combination of Python 2’s poor bytes/str behaviour, and the length and extension of the filename if you can believe that.

The check for “did you proivde raw file data to the constructor” is currently this:

isinstance(fileish, bytes) and fileish[8:12] == b'.FIT':

In Python 2, the passed in string is of type bytes and of course "76NE5832.FIT"[8:12] == ".FIT" so this returns True. It then assumes the filename is the raw bytes of the file. Of course, this breaks when it tries to read the header block from it.

I’ll have a fix soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FIT File Extension - What is it? How to open a FIT file?
If you cannot open your FIT file correctly, try to right-click or long-press the file. Then click "Open with" and choose an application....
Read more >
Opening FITS file problem | PixInsight Forum
I am able to open .fits files I collected ~1 month ago. I've tried dragging the file onto the Pixinsight workspace, same result....
Read more >
Problem opening FITS files. - AAVSO
Usually I get a "file format is not correct" message. I have been able to open the FITS with Notepad and can see...
Read more >
FIT Files: What It Is and How to Open It
The easiest way to open file extension FIT is to try downloading some of the most popular software that uses FIT extension. The...
Read more >
Error while opening FITS file - Siril - pixls.us
Hello, today I decided to try to process one of JWST's latest images and run in a problem that I wasn't able to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found