[Numpy-discussion] Loadtxt .bz2 support

Ryan May rmay31@gmail....
Wed Oct 22 15:59:30 CDT 2008


Charles R Harris wrote:
> On Tue, Oct 21, 2008 at 1:30 PM, Ryan May <rmay31@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.
> 

Done. #940

http://scipy.org/scipy/numpy/ticket/940

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma


More information about the Numpy-discussion mailing list