Sunday, 15 February 2015

Memory error reading a zip file in python -


I have a thread in which I am reading zip file with zipfile.ZipFile (). Read () , where I'm getting a memory error.

I know that read () loads the entire file in memory, after unzipping, the file size is more than 100MB i with zipfile.zipfile () Also tried ... Open (). Readlines () , but it takes a lot of time.

Is there a way that I can read the file speed without memory error?

Assume that you are trying to read a zipped text file, you can treat it An object like the file has been returned in the form of an iterator, and process it by line-by-line ...

  zipfile import from zipfile zip = zipfile ('myzip.zip ') Stream = Open to line in the ZIP stream (' myfile.txt '): do_something_with (line)    

No comments:

Post a Comment