[Numpy-discussion] problem reading binary data from file
Giorgio F. Gilestro
Fri Apr 6 11:14:20 CDT 2007
Here I go with my first problem for this ml!
I am reading a long sequence of binary data from a file using a call
similar to the following
numpy.core.records.fromfile (filename, formats='i2', byteorder='big')
My problem is that this function returns an array of tuples rather
than an array of actual values.
Basically I get something like this: [(45,) (29,) (23,)....(21,) (20,) (15,)]
While I would obviously prefer something like this: [45, 29, 23,
....., 21, 20, 15]
I can pass from one to the other through an iteration but this is
definitely time expensive.
I also know that if i specify the formats to be ['i2']*N I will get a
tuple of length N but that is not really feasible when my N is 5 *10^5
Is there any way I could get a 1D array (no tuples please!) directly
from the file?
(BTW numpy.core.records.fromstring gives the same output)
More information about the Numpy-discussion