[Numpy-discussion] problem reading binary data from file
Nadav Horesh
nadavh@visionsense....
Sat Apr 7 02:13:18 CDT 2007
How about:
numpy.fromfile(filename, dtype='>i2')
Nadav
-----Original Message-----
From: numpy-discussion-bounces@scipy.org on behalf of Pierre GM
Sent: Fri 06-Apr-07 18:41
To: Discussion of Numerical Python
Cc:
Subject: Re: [Numpy-discussion] problem reading binary data from file
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).
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 3017 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070407/8c9bb03d/attachment-0001.bin
More information about the Numpy-discussion
mailing list