[Numpy-discussion] difficulties with numpy.tofile()
Sun Nov 16 23:37:27 CST 2008
I'm having problems writing a 2-dimensional numpy array out to a binary
file using the "tofile" method. The call to "tofile" appears to
but when I check the length of the binary file I find that it's longer
than what is expected, given the calculation of nrows*ncolumns*nbytes.
The array that I'm writing out to the file is the result of running
kmeans2 (from scipy), so I'm expecting that the datatype is numpy.int32.
Is there an easy way to check what the datatype of a numpy array is?
Yet, the file that results from the call:
data.tofile('./data1.bin','int32') is longer than it should be.
Using "float32" as the datatype results in an even larger file, so it's
still longer than expected.
Does the "tofile" call insert some extra bytes at the beginning or end
of the binary file?
What is the best way of dumping a large numpy array to a binary file
can then be read in from Fortran?
I'm running python 2.5, numpy 1.2.1 on a Linux box with Fedora Core 7.
More information about the Numpy-discussion