[Numpy-discussion] loadtxt example problem ?

bruno Piguet bruno.piguet@gmail....
Mon May 4 15:06:54 CDT 2009


  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 ?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090504/284cd9c4/attachment.html 

More information about the Numpy-discussion mailing list