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

Stéfan van der Walt stefan at sun.ac.za
Thu Jul 2 18:53:21 EDT 2009


Hi Peter

2009/7/3 Peter Kelley <paz117 at gmail.com>:
> 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.

In your example the problem actually comes in with the string 'long',
which cannot be converted to a dtype using

dtype('long')

As for the strings, I think you'll have to pick the length of the
longest string and use that as the dtype:

np.dtype('S5') # where 5 is the longest

Good luck.

Regards
Stéfan



More information about the NumPy-Discussion mailing list