I have an N by 6 by f numpy array. I would like to be able to write this as a binary file and then read it by another python script into an array of the same dimensions.
To test this, I do the following (based on this question):
import numpy as np
farray=np.array([[3.14, 2.7, 0.0, -1.0, 1.1],[3.14, 2.7, 0.0, -1.0, 1.1]])
testf = open('test','wb')
farray.tofile(testf)
testf.close()
arraytest = np.fromfile('test')
At which point arraytest.shape is (10,). How can I make sure it is (2,5) instead without having to know 2 and 5 in advance to reshape the array? Can I somehow encode this information in the binary file as you would do with \n in a regular text file?