[Numpy-discussion] loadtxt error

Stéfan van der Walt stefan at sun.ac.za
Mon Sep 22 16:13:18 EDT 2008


2008/9/22 frank wang <f.yw at 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



More information about the NumPy-Discussion mailing list