3

I'd like to use python read a large binary file in ieee big endian 64bit floating point format, but am having trouble getting the correct values. I have a working method in matlab, as below:

fid=fopen(filename,'r','ieee-be');
data=fread(fid,inf,'float64',0,'ieee-be');
fclose(fid)

I've tried the following in python:

data = np.fromfile(filename, dtype='>f', count=-1)

This method doesn't throw any errors, but the values it reads are extremely large and incorrect. Can anyone help with a way to read these files? Thanks in advance.

1
  • Can you add a link to an example of a file like this? Commented Jul 16, 2018 at 23:03

1 Answer 1

4

Using >f will give you a single-precision (32-bit) floating point value. Instead, try

data = np.fromfile(filename, dtype='>f8', count=-1)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.