diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2008-09-09 13:38:34 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2008-09-09 13:38:34 +0000 |
commit | 27d5aff700a2841cc0a30a4f774dcc67363fa287 (patch) | |
tree | acd5e41bb946b90b8e4de50b219cdb806ee97277 /numpy/lib/io.py | |
parent | b01bf6ffea880fc28daaa6877e2d4653aeab3d7f (diff) | |
download | numpy-27d5aff700a2841cc0a30a4f774dcc67363fa287.tar.gz |
FIX: Loadtxt raises on empty input (closes #908).
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) |