On Mon, May 4, 2009 at 3:06 PM, bruno Piguet <bruno.piguet@gmail.com> wrote:
Hello,

  I'm new to numpy, and considering using loadtxt() to read a data file.

  As a starter, I tried the example of the doc page (http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html) :
 
>>> from StringIO import StringIO   # StringIO behaves like a file object
>>> c = StringIO("0 1\n2 3")
>>> np.loadtxt(c)
I didn't get the expectd answer, but :
Traceback (moste recent call last):
File"(stdin)", line 1, in <module>
File "C:\Python25\lib\sire-packages\numpy\core\numeric.py", line 725, in loadtxt
X = array(X, dtype)
ValueError: setting an array element with a sequence.
I'm using verison 1.0.4 of numpy).

I got the same problem on a Ms-Windows and a Linux Machine.

I could run the example by adding a \n at the end of c :
c = StringIO("0 1\n2 3\n")

Is it the normal and expected behaviour ?

Bruno.

It's a bug that's been fixed.  Numpy 1.0.4 is quite a bit out of date, so I'd recommend updating to the latest (1.3).

Ryan


--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma