Conversion of 24bit binary to int
Idar
ip at itk.ntnu.no
Wed Nov 12 04:53:17 EST 2003
On Tue, 11 Nov 2003 10:11:05 -0500, Peter Hansen <peter at engcorp.com> wrote:
> Idar wrote:
>>
>> Is there an effecient/fast way in python to convert binary data from
>> file
>> (24bit hex(int) big endian) to 32bit int (little endian)? Have seen
>> struct.unpack, but I am unsure how and what Python has to offer. Idar
>
> I think the question is unclear. You say you've seen struct.unpack.
> So what then? Don't you think struct.unpack will work? What do you
> mean you are unsure how and what Python has to offer? The documentation
> which is on the web site clearly explains how and what struct.unpack
> has to offer...
It is due to slack reading........
The doc says "Standard size and alignment are as follows: no alignment is
required for any type (so you have to use pad bytes)................"
It was unclear (at the time of reading) in the sence that I didn't see the
above text + there was no example on how to handle odd-byte/padding
conversion and the test program crashed!
But if you know how to convert this format (the file is about 6MB)
effeciently, pls do give me a hint. The data is stored binary with the
format:
Ch1: 1536B (512*3B)
..
Ch6 1536B (512*3B)
Then it is repeated again until end:
Ch1 1536B (512*3B)
..
Ch6 1536B (512*3B)
>
> Please clarify.
>
> -Peter
>
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
More information about the Python-list
mailing list