question on using format in struct module

Steve Holden sholden at
Thu Oct 25 02:32:02 CEST 2001

"Suresh" <mj_dup at> wrote ...
> Hi All,
> I need some help with struct module. I have a binary file (obtained
> with our product) and it contains char, int, float values. I used
> struct module for this purpose in this manner --
> import struct
> binfile = open('binary_file.bin','rb')
> format = ????
> bytes = struct.calcsize(format)
> i1, i2 and so on = struct.unpack(format,
> (i1, i2, i3 etc will have the equivalent text values of the binary
> fields from the "binary_file.bin")
> The problem is specifying for "format" variable. Since my binary file
> has non-uniform and different data types how do I specify for format =
> ???? Is there a way I can tell python to decide upon format looking at
> the binary file. Any help is appreciated !
So, what you are sayng is that you don't know the format of the tile, and
you'd like someone to tell you how to decode it? If *you* don't know how to
decode your application's data, how do you expect someone else to? I must be
missing something.

Maybe there's something you can use in

which reads binary files from Outlokk Express.


More information about the Python-list mailing list