[Numpy-discussion] genfromtext advice

Tim Michelsen timmichelsen at gmx-topmail.de
Tue Sep 1 06:08:28 EDT 2009


Hello,
I tried to load a ASCII table into a string array. Unfortunately, this table has
some empty chells

Here it is:
http://www.ncdc.noaa.gov/oa/climate/rcsg/cdrom/ismcs/alphanum.html

After having converted this into a text file I tried this:

$ np.genfromtxt('alphanum_to-text.txt', dtype=np.str_, delimiter='|',
skiprows=1, missing='')

But I got an error:

   1043                         dtype = np.dtype(ttype)
   1044             #
-> 1045             output = np.array(data, dtype)
   1046             if usemask:
   1047                 if dtype.names:

ValueError: setting an array element with a sequence

I sometimes experience this error message with text read in. Could this message
be made more helpful like telling in which line of the input file this occurs?
This could really reduce the trial and error.

What would be the correct way to read this data in?

Thanks,
Timmie




More information about the NumPy-Discussion mailing list