read Zipfile

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Nov 2 20:19:01 EST 2009


En Mon, 02 Nov 2009 20:39:07 -0300, sityee kong <skong1 at gmail.com>  
escribió:

> However for the ZIP file, let says the ZIP file contains only one member,
>>>> archive.namelist()
> ['CHAVI_MACS_SC_A__AUG_25_08_FinalReport_090812.csv']
>
> I would like to open the csv file with folowwing command,
> file=archive.open("CHAVI_MACS_SC_A__AUG_25_08_FinalReport_090812.csv","r")
> But it turned out error,
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> AttributeError: ZipFile instance has no attribute 'open'
>
> Do you know the way to open an file from a ZIP archive, but not reading  
> them
> all into memory. I would manipulate each line using "for line in file:"

open was added to the ZipFile class in Python 2.6; which version are you  
using?
I think you can backport the 2.6 version onto 2.5 with little or no effort.
http://docs.python.org/library/zipfile.html#zipfile.ZipFile.open

> Hope my contents do make sense.

Yes, it was clear to me.

-- 
Gabriel Genellina




More information about the Python-list mailing list