Can't open FIT file
See original GitHub issueIs 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:
- Created 6 years ago
- Comments:5
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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?
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:
In Python 2, the passed in string is of type
bytes
and of course"76NE5832.FIT"[8:12]
==".FIT"
so this returnsTrue
. 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.