[Numpy-discussion] np.loadtxt : yet a new implementation...

Christopher Barker Chris.Barker at noaa.gov
Wed Dec 3 13:00:58 EST 2008


by the way, should this work:

io.loadtxt('junk.dat', delimiter=' ')

for more than one space between numbers, like:

1  2  3  4   5
6  7  8  9  10

I get:

io.loadtxt('junk.dat', delimiter=' ')
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/numpy/lib/io.py", 
line 403, in loadtxt
     X.append(tuple([conv(val) for (conv, val) in zip(converters, vals)]))
ValueError: empty string for float()

with the current version.

 >>> io.loadtxt('junk.dat', delimiter=None)
array([[  1.,   2.,   3.,   4.,   5.],
        [  6.,   7.,   8.,   9.,  10.]])

does work.



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov



More information about the NumPy-Discussion mailing list