[Numpy-discussion] loadtxt error

frank wang f.yw@hotmail....
Mon Sep 22 18:56:47 CDT 2008

This error is caused that the usecols is a tuple and it does not have find command. I do not know how to fix this problem.

From: f.yw@hotmail.comTo: numpy-discussion@scipy.orgDate: Mon, 22 Sep 2008 15:27:13 -0600Subject: Re: [Numpy-discussion] loadtxt error

Hi, Stefan, Thanks for your help. First it is my typing error. My command is:fid=loadtxt('filename.csv',comments='"',dtype='|S4',converters={1:lambdas:int(s,16)},usecols=(1,)) It is not the zero. This will causes the same error as:In [218]: fid=loadtxt('test.dat',comments='"',dtype='|S4',converters={1:lambda s:int(s,16)},usecols=(1,))---------------------------------------------------------------------------AttributeError                            Traceback (most recent call last)C:\DHG\DOCSIS\lab_test\parseadc.py in <module>()----> 1      2      3      4      5C:\Python25\lib\site-packages\numpy\lib\io.pyc in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack)    337     for i, conv in (user_converters or {}).iteritems():    338         if usecols:--> 339             i = usecols.find(i)    340         converters[i] = conv    341AttributeError: 'tuple' object has no attribute 'find'> c:\python25\lib\site-packages\numpy\lib\io.py(339)loadtxt()    338         if usecols:--> 339             i = usecols.find(i)    340         converters[i] = conv This command is the same as yours. I do not know why it is working for you.> Date: Mon, 22 Sep 2008 22:13:18 +0200> From: stefan@sun.ac.za> To: numpy-discussion@scipy.org> Subject: Re: [Numpy-discussion] loadtxt error> > 2008/9/22 frank wang <f.yw@hotmail.com>:> > It will load an array has two columns. However, I only want to load one> > column to save the memory. If I type> >> > fid=loadtxt('filename.csv',comments='"',dtype='|S4',converters={0:lambda> > s:int(s,16)},usecols=(1,))> > You are specifying a converter that won't be in the output. I can fix> that, but in the meantime do:> > np.loadtxt('dat.dat',comments='"',dtype='|S4',converters={1:lambda> s:int(s,16)},usecols=(1,))> [(565,), (919,)]> |S4> > Regards> Stéfan> _______________________________________________> Numpy-discussion mailing list> Numpy-discussion@scipy.org> http://projects.scipy.org/mailman/listinfo/numpy-discussion

See how Windows connects the people, information, and fun that are part of your life. See Now 
See how Windows Mobile brings your life together—at home, work, or on the go.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080922/90cbf4b4/attachment.html 

More information about the Numpy-discussion mailing list