diff options
Diffstat (limited to 'numpy/lib/io.py')
-rw-r--r-- | numpy/lib/io.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/numpy/lib/io.py b/numpy/lib/io.py index 5348866c4..93c955942 100644 --- a/numpy/lib/io.py +++ b/numpy/lib/io.py @@ -312,10 +312,10 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, converters=None, """ user_converters = converters - - if usecols is not None: - usecols = list(usecols) - + + if usecols is not None: + usecols = list(usecols) + if _string_like(fname): if fname.endswith('.gz'): import gzip @@ -361,6 +361,8 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, converters=None, first_vals = None while not first_vals: first_line = fh.readline() + if first_line == '': # EOF reached + raise IOError('End-of-file reached before encountering data.') first_vals = split_line(first_line) N = len(usecols or first_vals) |