[Numpy-discussion] genfromtext advice

Pierre GM pgmdevlist@gmail....
Tue Sep 1 05:37:40 CDT 2009


On Sep 1, 2009, at 6:08 AM, Tim Michelsen wrote:

> 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?

Mmh, perhaps. I'll try to see what I can do. Usually, this message  
shows up when one of the lines you have read doesn't have the same  
number of columns as the others. You mentioned that you're skipping  
one line : try skipping a few more and check.
I can't really see what could go wrong in the link you sent. However,  
you converted it to txt, right ? You're 100% sure that you didn't miss  
something in the conversion ? Can you post the result  (or send a link  
to?)



More information about the NumPy-Discussion mailing list