[Numpy-discussion] Add `nrows` to `genfromtxt`

Warren Weckesser warren.weckesser at gmail.com
Sun Nov 2 14:32:55 EST 2014


On Sun, Nov 2, 2014 at 2:18 PM, Alexander Belopolsky <ndarray at mac.com>
wrote:

>
> On Sun, Nov 2, 2014 at 1:56 PM, Warren Weckesser <
> warren.weckesser at gmail.com> wrote:
>
>> Or you could just call genfromtxt() once with `max_rows=1` to skip a
>> row.  (I'm assuming that the first argument to genfromtxt is the open file
>> object--or some other iterator--and not the filename.)
>
>
> That's hackish.  If I have to resort to something like this, I would just
> call next() on the open file object or iterator.
>


I agree, calling genfromtxt to skip a line is silly.  Calling next() makes
much more sense.



>
> Still, the case of dtype=None, name=None is problematic.   Suppose I want
> genfromtxt()  to detect the column names from the 1-st row and data types
> from the 3-rd.  How would you do that?
>
>

This may sound like a cop out, but at some point, I stop trying to make
genfromtxt() handle every possible case, and instead I would write a custom
header reader to handle this.

Warren



> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141102/8497dc4d/attachment.html>


More information about the NumPy-Discussion mailing list