I need to read a simple but large (500MB) binary file in Python 3.6. The file was created by a C program, and it contains 64-bit double precision data. I tried using struct.unpack but that's very slow for a large file.
Here is my simple file read:
def ReadBinary():
fileName = 'C:\\File_Data\\LargeDataFile.bin'
with open(fileName, mode='rb') as file:
fileContent = file.read()
Now I have fileContent. What is the fastest way to decode it into 64-bit double-precision floating point, or read it without the need to do a format conversion?
I want to avoid, if possible, reading the file in chunks. I would like to read it decoded, all at once, like C does.
mmap? See the accepted answer here stackoverflow.com/a/30022899/10035985