[Numpy-discussion] loadtxt and usecols

Irvin Probst irvin.probst at ensta-bretagne.fr
Tue Nov 10 04:24:57 EST 2015

On 10/11/2015 09:19, Sebastian Berg wrote:
> since a scalar row (so just one row) is read and not a 2D array. I tend
> to say it should be an array-like argument and not a generalized
> sequence argument, just wanted to note that, since I am not sure what
> matlab does.

By default Matlab reads everything, silently fails on what can't be 
converted into a float and the user has to guess what was read or not.
Say you have a file like this:

2010-01-01 00:00:00         3.026
2010-01-01 01:00:00         4.049
2010-01-01 02:00:00         4.865

 >> M=load('CONCARNEAU_2010.txt');
 >> M(1:3,:)

ans =

    1.0e+03 *

     2.0100         0    0.0030
     2.0100    0.0010    0.0040
     2.0100    0.0020    0.0049

I think this is a terrible way of doing it even if newcomers might find 
this handy. There are of course optionnal arguments (even regexps !) but 
to my knowledge almost no Matlab user even knows these arguments are there.

Anyway, I made a PR here https://github.com/numpy/numpy/pull/6656 with 
usecols as an array-like.


More information about the NumPy-Discussion mailing list