[Numpy-discussion] genfromtxt view with object dtype

Brent Pedersen bpederse@gmail....
Wed Feb 4 11:09:51 CST 2009

hi, i am using genfromtxt, with a dtype like this:
[('seqid', '|S24'), ('source', '|S16'), ('type', '|S16'), ('start',
'<i4'), ('end', '<i4'), ('score', '<f8'), ('strand', '|S1'), ('phase',
'<i4'), ('attrs', '|O4')]

where i'm having problems with the attrs column which i'd like to be a
dict. i can specify a convertor to parse a string into a dict, and it
is correctly converted to a dict,
but then in io.py it tries to take a view() of that dtype and it gives
the error:

    A = np.genfromtxt(fname, **kwargs)
  File "/usr/lib/python2.5/site-packages/numpy/lib/io.py", line 922,
in genfromtxt
    output = rows.view(dtype)
 TypeError: Cannot change data-type for object array.

is there anyway around this or must that col be kept as a string?
it seems like genfromtxt expects you to specify either a dtype _or_ a
convertor, not both.


More information about the Numpy-discussion mailing list