diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2019-08-14 18:33:34 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-14 18:33:34 -0600 |
commit | 908fa68a1978ea0826f1761ea5688e8c58111ae9 (patch) | |
tree | bea8b8f647bb9ca2afb12c878db425c9e28494fb /numpy/lib/npyio.py | |
parent | 5e7e74beb88e201e81db13fac7cc1d61014695f2 (diff) | |
parent | 99acd16d9582a78b11561108b63db3aacb042ccc (diff) | |
download | numpy-908fa68a1978ea0826f1761ea5688e8c58111ae9.tar.gz |
Merge pull request #14252 from maxwell-aladago/genfromtext
BUG: Fixes StopIteration error from 'np.genfromtext' for empty file with skip_header > 0
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r-- | numpy/lib/npyio.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index b9dc444f8..746e6043a 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -1776,12 +1776,13 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, replace_space=replace_space) # Skip the first `skip_header` rows - for i in range(skip_header): - next(fhd) - - # Keep on until we find the first valid values - first_values = None try: + for i in range(skip_header): + next(fhd) + + # Keep on until we find the first valid values + first_values = None + while not first_values: first_line = _decode_line(next(fhd), encoding) if (names is True) and (comments is not None): |