Reading binary files
drsalists at gmail.com
Mon Aug 31 05:27:55 CEST 2009
David Robinow wrote:
>>> This works for a simple binary file, but the actual file I'm trying to
>>> read is give throwing an error that the file cannot be found. Here is the
>>> name of the my file:
>>> Should python have trouble reading this file name or extension?
>> I'm having trouble with the filename:
>> It throws an error with that file name, When I change it to something like
>> sample.txt it runs, but the data is still garbled. Is there any reason why I
>> can't use the above file name? If I'm using 'rb' to read the binary file why
>> is it still garbled?
> I don't think it's garbled. It's a binary file. What do you expect?
> It's been over ten years since I've worked with any JSTARS stuff so I
> can't give you any details but you almost certainly have some sort of
> imagery. The military has a lot of bizarre formats and whoever sent
> you the data should have included a data sheet describing the format
> (or a pointer to such). Ideally, you'll also get a pointer to code to
> read the thing, but sometimes you just have to bite the bullet and
> write a program to process the file.
> (If all else fails, look at a dump of the first 512 bytes or so;
> often the image size is included at the beginning; maybe in ASCII, 16
> bit ints, 32 bit ints, floating point -- who knows)
> There've been times when I had to just display the thing at 512 or
> 1024 bytes (or ints) per row and try to surmise the info from that.
> So, look for the file description.
> Googling a bit: I see there's a package at
> which purports to handle some JSTARS stuff. I've no idea if that will help you.
If you don't find anything preexisting for reading JSTARS format, this
More information about the Python-list