[Numpy-discussion] numpy.loadtxt requires seek()?

Ryan May rmay31 at gmail.com
Thu Nov 20 14:58:33 EST 2008


Stéfan van der Walt wrote:
> 2008/11/20 Ryan May <rmay31 at gmail.com>:
>> Does anyone know why numpy.loadtxt(), in checking the validity of a
>> filehandle, checks for the seek() method, which appears to have no
>> bearing on whether an object will work?
> 
> I think this is simply a naive mistake on my part.  I was looking for
> a way to identify files; your patch would be welcome.

I've attached a simple patch that changes the check for seek() to a
check for readline().  I'll punt on my idea of just using iterators,
since that seems like slightly greater complexity for no gain. (I'm not
sure how many people end up with data in a list of strings and wish they
could pass that to loadtxt).

While you're at it, would you commit my patch to add support for bzipped
files as well (attached)?

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: loadtxt_bzip2_support.diff
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20081120/cf9e41be/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: loadtxt_filecheck_readline.diff
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20081120/cf9e41be/attachment-0001.ksh>


More information about the NumPy-Discussion mailing list