I have to extract the following data from that file:
Byte Offset: 176
Data type: 4-byte (long) integer
Total bytes: 160
I tried as follows:
import numpy as np
fname = 'GLA06_634_1102_001_0079_3_01_0001.DAT'
with open(fname,'rb') as fi:
fi.seek (176,0)
data= np.fromfile(fi,dtype='long',count=160)
print data
No success, what's wrong with my idea?
解决方案
Using a hard coded offset is a rather fragile solution. But assuming you know what you are doing:
Byte Offset: 176
Data type: 4-byte (long) integer
Total bytes: 160
AKAICT, that leads to 160/4 = 40 values to read (could you confirm that?)
In addition, the type should be one of the numpy defined type. Here np.int32 might be the right one:
data=