3 Jul 00:42
Using loadtxt to read in mixed data types
Peter Kelley <paz117 <at> gmail.com>
2009-07-02 22:42:09 GMT
2009-07-02 22:42:09 GMT
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
RSS Feed