Re: [Numpy-discussion] problem reading binary data from file

2007-04-06 Thread Nadav Horesh
How about: numpy.fromfile(filename, dtype='>i2') Nadav -Original Message- From: [EMAIL PROTECTED] 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

Re: [Numpy-discussion] problem reading binary data from file

2007-04-06 Thread Christopher Barker
> In fact numpy.fromfile was the first function I tried to use but I > couldn't manage to get it working with the byteorder I needed > (big-endian). a = fromfile(...) a.byteswap(True) -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-6959

Re: [Numpy-discussion] problem reading binary data from file

2007-04-06 Thread Giorgio F. Gilestro
Thanks to everyone, really. I already know this ml is going to be as useful as numpy itself! In fact numpy.fromfile was the first function I tried to use but I couldn't manage to get it working with the byteorder I needed (big-endian). The ['f0'] trick works very nicely though, so I think I'll us

Re: [Numpy-discussion] problem reading binary data from file

2007-04-06 Thread Christopher Barker
Pierre GM wrote: > With numpy.core.records, you create a record array. Just get the field ('f0' > by default) to get a ndarray. there is. Don't use numpy.core.records. Use numpy.fromfile: import numpy a = numpy.fromfile(filename, dtype=numpy.int16) (filename can be a filename, or an open file

Re: [Numpy-discussion] problem reading binary data from file

2007-04-06 Thread Travis Oliphant
Giorgio F. Gilestro wrote: >Hello everyone. > >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

Re: [Numpy-discussion] problem reading binary data from file

2007-04-06 Thread Pierre GM
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.c

[Numpy-discussion] problem reading binary data from file

2007-04-06 Thread Giorgio F. Gilestro
Hello everyone. 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 tha