diff options
Diffstat (limited to 'numpy/lib/io.py')
-rw-r--r-- | numpy/lib/io.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/numpy/lib/io.py b/numpy/lib/io.py index b85022203..e9a012db1 100644 --- a/numpy/lib/io.py +++ b/numpy/lib/io.py @@ -279,8 +279,8 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, converters=None, Parameters ---------- fname : file or string - File or filename to read. If the filename extension is ``.gz``, - the file is first decompressed. + File or filename to read. If the filename extension is ``.gz`` or + ``.bz2``, the file is first decompressed. dtype : data-type Data type of the resulting array. If this is a record data-type, the resulting array will be 1-dimensional, and each row will be @@ -346,6 +346,9 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, converters=None, if fname.endswith('.gz'): import gzip fh = gzip.open(fname) + elif fname.endswith('.bz2'): + import bz2 + fh = bz2.BZ2File(fname) else: fh = file(fname) elif hasattr(fname, 'readline'): |