diff options
author | Maxwell Aladago <maxwell.aladago@gmail.com> | 2019-08-11 09:47:12 -0400 |
---|---|---|
committer | Maxwell Aladago <maxwell.aladago@gmail.com> | 2019-08-11 09:47:12 -0400 |
commit | 99acd16d9582a78b11561108b63db3aacb042ccc (patch) | |
tree | a10447b963d857f92c2c366a48ba624071abcb26 /numpy/lib/npyio.py | |
parent | ddb4a68ba6308dafd07dd40325d9438b3030c132 (diff) | |
download | numpy-99acd16d9582a78b11561108b63db3aacb042ccc.tar.gz |
fixes StopIteration error 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): |