Hello,
I am trying to head in a binary file that has a header and different character types. The array module apparently expects the typecode to be the same throughout. Here's what the file looks like:
Byte number: type: value: purpose:
1-4 char “ver.”
5-8 char “0001” version number
9-12 int 1, 2, 3, or 4 data type: 1=unsigned byte 2=unsigned short 3=32-bit integer 4=32-bit floating point
13-16 int x dimension, xdim
7-20 int y dimension, ydim
20-24 int z dimension, zdim
25-28 int xdim*ydim*zdim
The rest of the file contains the data array of type in indicated in bytes 9-12.
I have tried:
import Numeric as N
import array
fileobj = open(myfile, mode='rb')
s = array.array('f')
s.read(fileobj, size)
data = "" typecode=N.Int)
fileobj.close()
But the header must confuse things because I do get what I expect.
Any advice?
Best Regards,
Dan
Daniel R Einstein, PhD
Biological Monitoring and Modeling
Pacific Northwest National Laboratory
P.O. Box 999; MSIN P7-59
Richland, WA 99352
Tel: 509/ 376-2924
Fax: 509/376-9064
[EMAIL PROTECTED]
-- http://mail.python.org/mailman/listinfo/python-list