[Numpy-discussion] Loadtxt .bz2 support
Charles R Harris
charlesr.harris at gmail.com
Tue Oct 21 23:59:40 EDT 2008
On Tue, Oct 21, 2008 at 1:30 PM, Ryan May <rmay31 at gmail.com> wrote:
> Hi,
>
> I noticed numpy.loadtxt has support for gzipped text files, but not for
> bz2'd files. Here's a 3 line patch to add bzip2 support to loadtxt.
>
> Ryan
>
> --
> Ryan May
> Graduate Research Assistant
> School of Meteorology
> University of Oklahoma
>
> Index: numpy/lib/io.py
> ===================================================================
> --- numpy/lib/io.py (revision 5953)
> +++ numpy/lib/io.py (working copy)
> @@ -320,6 +320,9 @@
> 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, 'seek'):
>
Could you open a ticket for this? Mark it as an enhancement.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20081021/77be375d/attachment.html>
More information about the NumPy-Discussion
mailing list