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

Alexander Belopolsky ndarray at mac.com
Sun Nov 2 16:18:51 EST 2014

On Sun, Nov 2, 2014 at 2:32 PM, Warren Weckesser <warren.weckesser at gmail.com
> wrote:

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

In the abstract, I would agree with you.  It is often the case that 2-3
lines of clear Python code is better than a terse function call with half a
dozen non-obvious options.  Specifically, I would be against the proposed
slice_rows because it is either equivalent to  genfromtxt(islice(..), ..)
or hard to specify.

On the other hand, skip_rows is different for two reasons:

1. It is not a new option.  It is currently a deprecated alias to
skip_header, so a change is expected - either removal or redefinition.
2. The intended use-case - inferring column names and type information from
a file where data is separated from the column names is hard to code
explicitly.  (Try it!)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141102/36f634ad/attachment.html>

More information about the NumPy-Discussion mailing list