[Numpy-discussion] problem reading binary data from file

Pierre GM pgmdevlist@gmail....
Fri Apr 6 11:41:01 CDT 2007


On Friday 06 April 2007 12:14:20 Giorgio F. Gilestro wrote:

> 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)

numpy.core.records.fromfile (filename, formats='i2', byteorder='big')['f0']

With numpy.core.records, you create a record array. Just get the field ('f0' 
by default) to get a ndarray.

(I'm sure there's a simpler way, but that should do it for now).


More information about the Numpy-discussion mailing list