I’m trying to read a binary file that consists of 2 byte floats, but I cant seem to get the values I want. struct.unpack seems to only work for 4 byte floats and I’m not sure what else is available other than doing the cast completely manually. Is there any way to do this? Any help would be very much appreciated.
Share
You’ve already got most of the way with
numpy.fromfile. Instead usenumpy.frombuffer:If the data has a known form you can parse out structs by creating a dtype with the appropriate layout.