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

Peter Kelley paz117 at gmail.com
Thu Jul 2 18:42:09 EDT 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
this:

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

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.

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


More information about the NumPy-Discussion mailing list