[Numpy-discussion] genfromtxt

Brent Pedersen bpederse@gmail....
Wed Jan 21 14:14:44 CST 2009


hi, i'm using the new genfromtxt stuff in numpy svn, looks great
pierre any who contributed.
is there a way to have the header commented and still be able to have
it recognized as the header? e.g.

#gender age weight
M   21  72.100000
F   35  58.330000
M   33  21.99

if i use np.loadtxt or genfromtxt, it tries to use the 2nd row (first
non-commented as the header).
and i get an array like:
array([('M', 21, 72.099999999999994), ('F', 35, 58.329999999999998),
      ('M', 33, 21.989999999999998)],
     dtype=[('f0', '|S1'), ('f1', '<i4'), ('f2', '<f8')])

when i want:

array([('M', 21, 72.099999999999994), ('F', 35, 58.329999999999998),
      ('M', 33, 21.989999999999998)],
     dtype=[('gender', '|S1'), ('age', '<i4'), ('weight', '<f8')])

i can get that by uncommenting the header, but it's useful to have
that for other code.
is there anyway to do that?
thanks,
-brent


More information about the Numpy-discussion mailing list