This is a binary file with a very simple structure for learning purposes. Each register has 3 numbers: a 32-bit float, a 64-bit float and another 32-bit float. If I dump it on the screen in hexadecimal, it looks like this:
0000000: 0800 0000 0000 0000 0000 0000 0800 0000 ................
0000010: 0800 0000 0000 0000 0000 f03f 0800 0000 ...........?....
0000020: 0800 0000 182d 4454 fb21 0940 0800 0000 .....-DT.!.@....
(...)
If I manually copy the third line in binary format, I can read it into three variables:
import struct
data = b'\x08\x00\x00\x00\x18-DT\xfb!\t@\x08\x00\x00\x00'
l1, value, l2 = struct.unpack("<idi", data)
# (8, 3.141592653589793, 8)
That works, but I need to read the file from disk, not only manually copying each register in binary, because I need to do this with millions data. I need something equivalent to the following command used in ascii files:
l1, value, l2 = pylab.loadtxt('./test_file.binary',unpack=True)
Which doesn't work here.