1

I usually use IDL for data analysis. So when I open a XDR file, I used openr function with /XDR keyword. Now I try to change the IDL code to Python, but I dont know how to read the XDR files.

for example in IDL, I can open the file using below sentence

openr,1,file,/XDR

and read the data using

readu,1,h1,h2,h3,h4
readu,1,p_h1,p_h2,p_h3,p_h4
readu,1,p1,p2,p3,p33,p4,p5,p6,AP12
.....

however, when I try to read the data in Python

with open(file, 'rb') as f:
    data = f.readlines()     
u = xdrlib.Unpacker(data)
print('unpacked:', u.unpack_uint(), repr(u.unpack_string()))

It doesn't work... Would you guys please give me some advice ?

이원석
  • 87
  • 2
  • 5

0 Answers0