classification
Title: Better way to read files from ZipFiles
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: postponed
Dependencies: Superseder:
Assigned To: fdrake Nosy List: fdrake, itamar
Priority: normal Keywords: patch

Created on 2001-05-17 14:33 by itamar, last changed 2001-07-04 05:37 by fdrake. This issue is now closed.

Files
File name Uploaded Description Edit
zipfile.patch itamar, 2001-05-17 14:33 Zipfile patch
Messages (2)
msg36608 - (view) Author: Itamar Shtull-Trauring (itamar) Date: 2001-05-17 14:33
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.
msg36609 - (view) Author: Fred L. Drake, Jr. (fdrake) (Python committer) Date: 2001-07-04 05:37
Logged In: YES 
user_id=3066

The test definately needs to be better, and documentation is
also required.

Postponing the patch pending an update.
History
Date User Action Args
2001-05-17 14:33:11itamarcreate