[Numpy-discussion] numpy loadtxt - ValueError: setting an array element with a sequence.

Pierre GM pgmdevlist@gmail....
Thu Oct 29 13:31:24 CDT 2009


On Oct 29, 2009, at 8:30 AM, TheLonelyStar wrote:

>
> Adter trying the same thing in matlab, I realized that my "tsv" file  
> is not
> matrix-style. But this I mean, not all lines ave the same lenght  
> (not the
> same number of values).
>
> What would be the best way to load this?

The SVN version of np.genfromtxt will let you know where some rows are  
longer than others. You can decide what to do from then (ignore the  
corresponding rows or modify your file).
The .fromfile approach is a solution if you don't really care about  
getting a 2D array (or structured 1D array with different fields for  
ints and floats on a same row), as a previous poster illustrated.



More information about the NumPy-Discussion mailing list