Peter Kelley | 3 Jul 00:42
Picon

Using loadtxt to read in mixed data types


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

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion <at> scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Gmane