[Numpy-discussion] Using loadtxt to read in mixed data types

Peter Kelley paz117@gmail....
Thu Jul 2 17:42:09 CDT 2009

Hey Everyone,

I am reading in a file of columns with mixed data types, and the number of
columns can vary and their format is inputted by the user. So I came up with

dt=dtype({'names': [x for x in event_fields], 'formats': [b for b in

eventArray = loadtxt(behEventFile,dt)

where event_format is ['long', 'int', 'int', 'int', 'int', 'int', 'str',
'str', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int']

I get TypeError: data type not understood, and I think it is because the
event format is a list of strings not data types. Does anyone have know how
to convert the list of strings into the data types for dtype.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090702/95e6c516/attachment.html 

More information about the Numpy-discussion mailing list