From 7adaad411b9896f7dd8100cb75e80a313c082d2c Mon Sep 17 00:00:00 2001 From: pierregm Date: Thu, 22 Jan 2009 05:37:36 +0000 Subject: * genfromtxt : if names is True, accept a line starting with a comment character as header. --- numpy/lib/io.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'numpy/lib/io.py') diff --git a/numpy/lib/io.py b/numpy/lib/io.py index 303796d5f..5a3a077cb 100644 --- a/numpy/lib/io.py +++ b/numpy/lib/io.py @@ -748,7 +748,14 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, skiprows=0, first_line = fhd.readline() if first_line == '': raise IOError('End-of-file reached before encountering data.') - first_values = split_line(first_line) + if names is True: + first_values = first_line.strip().split(delimiter) + else: + first_values = split_line(first_line) + if names is True: + fval = first_values[0].strip() + if fval in comments: + del first_values[0] # Check the columns to use if usecols is not None: -- cgit v1.2.1