8000 Allow file comments with genfromtxt(..., names=True) · numpy/numpy@9f45975 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9f45975

Browse files
committed
Allow file comments with genfromtxt(..., names=True)
1 parent 143fb18 commit 9f45975

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

numpy/lib/npyio.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,9 +1237,6 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
12371237
-----
12381238
* When spaces are used as delimiters, or when no delimiter has been given
12391239
as input, there should not be any missing data between two fields.
1240-
* When the variables are named (either by a flexible dtype or with `names`,
1241-
there must not be any header in the file (else a ValueError
1242-
exception is raised).
12431240
* Individual values are not stripped of spaces by default.
12441241
When using a custom converter, make sure the function does remove spaces.
12451242
@@ -1347,7 +1344,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
13471344
first_line = fhd.next()
13481345
if names is True:
13491346
if comments in first_line:
1350-
first_line = asbytes('').join(first_line.split(comments)[1:])
1347+
first_line = first_line.split(comments)[0]
13511348
first_values = split_line(first_line)
13521349
except StopIteration:
13531350
# return an empty array if the datafile is empty

0 commit comments

Comments
 (0)
0