Hi, I tried to load data from a csv file into numpy using genfromtxt. I need only a subset of the columns and want to apply some conversions to the data. attached is a minimal script showing the error. In brief, I want to load columns 1,2 and 4. But in the converter function for the 4th column, I get the 3rd value. The issue does not occur if I also load the 3rd column. Did I somehow misunderstand how the function is supposed to work or is this indeed a bug?
I'm using python 3.3.1 with numpy 1.8.1 Regards Adrian
import numpy import io off1, off2 = 0, 4000 dtype = [('EntryNr1','i4'),('EntryNr2','i4'),('RelType', 'i1')] fn = io.BytesIO("""1,5,-1,1:1,1.98\n2,8,-1,1:n,22.56\n3,3,-2,m:n,18.2\n""".encode('utf-8')) relEnum = {'1:1':0, '1:n':1, 'm:1':2, 'm:n':3} data = numpy.genfromtxt(fn, dtype=dtype, delimiter=',', usecols=(0,1,3), converters={0: lambda nr: int(nr)+off1, 1: lambda nr: int(nr)+off2, 3: lambda rel: relEnum[rel.decode()]})
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion