[Numpy-discussion] difficulties with numpy.tofile()
Charles R Harris
charlesr.harris@gmail....
Sun Nov 16 23:47:14 CST 2008
On Sun, Nov 16, 2008 at 10:37 PM, Catherine Moroney <
catherine.m.moroney@jpl.nasa.gov> wrote:
> Hello,
>
> 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
> succeed,
> 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.
>
You might find the following attributes useful in debugging this.
In [1]: x = ones((2,2))
In [2]: x.size
Out[2]: 4
In [3]: x.itemsize
Out[3]: 8
In [4]: x.nbytes
Out[4]: 32
In [5]: x.dtype
Out[5]: dtype('float64')
In [6]: x.tofile('foo.dat')
In [7]: ls -l foo.dat
-rw-rw-r-- 1 charris charris 32 2008-11-16 22:43 foo.dat
The file should have the same size as x.nbytes. What operating system are
you using?
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20081116/0fc80ed9/attachment.html
More information about the Numpy-discussion
mailing list