python - Want to check this script I wrote to read a Fortran binary file -


i'm working on project requires me read fortran binary files. understanding fortran automatically puts 4-byte header , footer each file. such, want remove first , last 4 bytes file before read it. trick?

a = open("foo",rb) b = a.seek(4,0)  x = np.fromfile(b.seek(4,2),dtype='float64') 

it might easier read entire file , chop 4 bytes off each end:

a = open("foo","rb") data = a.read() a.close()  x = np.fromstring(data[4:-4], dtype='float64') 

for similar question, see how read part of binary file numpy?


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -