extracting zip item to in-memory

Dave Angel davea at davea.name
Wed May 6 16:38:21 EDT 2015


On 05/06/2015 04:27 PM, noydb wrote:
> I have a zip file containing several files and I want to extract out just the .xml file.  I have that code.  Curious if this xml file can be extracted into memory.  If so, how to?  I only need to move the file around, and maybe read some tags.
>
> Thanks for any help!
>
> python 2.7
>

See https://docs.python.org/2.7/library/zipfile.html#zipfile.ZipFile.open

To open a particular member and get back a file-like object.

Once you have that, you can use the  read() method of that object.

Once you've coded this, if it doesn't work, post what you've got with a 
description of what doesn't work, and somebody here will be able to fix 
it up.


-- 
DaveA



More information about the Python-list mailing list