[Patches] [ python-Patches-424856 ] Better way to read files from ZipFiles
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 03 Jul 2001 22:37:08 -0700
Patches item #424856, was opened at 2001-05-17 07:33
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=424856&group_id=5470
Category: library
Group: None
>Status: Pending
>Resolution: Postponed
Priority: 5
Submitted By: Itamar Shtull-Trauring (itamar)
>Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: Better way to read files from ZipFiles
Initial Comment:
RIght now, reading a file from a ZipFile loads the
whole file into memory and returns it as a string. This
makes the module useless for large files.
My patch allows you to get a file-like object for each
entry in the zip, so you can do:
f = z.readfile("largfile")
print f.read(500)
Instead of the current method:
s = z.read("largefile")
print s[:500]
Much nicer if "largefile" is a 10MB file...
I added a function ZipFile.readfile, two classes for
the file-like objects (uncompressed and deflated), and
reimplemented ZipFile.read to use ZipFile.readfile. I
also added a small test to test_zipfile.py, although
some more extensive testing would be better, as usual.
I will be using this code in a project, which'll
provide additional testing.
----------------------------------------------------------------------
>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2001-07-03 22:37
Message:
Logged In: YES
user_id=3066
The test definately needs to be better, and documentation is
also required.
Postponing the patch pending an update.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=424856&group_id=5470