[Numpy-discussion] Proposed change in genfromtxt(..., comments='#', names=True) behaviour

Nathaniel Smith njs@pobox....
Mon Jul 16 15:14:48 CDT 2012


On Mon, Jul 16, 2012 at 9:01 PM, Pierre GM <pgmdevlist@gmail.com> wrote:
> Well, as `skip_header` is a number of lines, I don't really see anything
> particular magical about a `skip_header=-1`.

The logic here is:
- if names=True, then genfromtext expects the names to be given in the
first line, and they may or may not be commented out
- BUT, if skip_header=<some special value>, then any all-comment lines
will be skipped before looking for names, i.e. the names are not
expected to be commented out and comments are given their original
meaning again.

I have no idea how one could derive this understanding by looking at
skip_header=-1. "Ah, that -1 is a number of lines, everyone knows that
skipping -1 lines is equivalent to toggling our expectation for
whether the column names will appear inside a comment"? The API is
pretty convoluted at this point and I'm not convinced we wouldn't be
better off with adding a new argument like
names_in_comment=False/True, but skip_header="comments" at least gives
the reader a fighting chance...

-n


More information about the NumPy-Discussion mailing list