read Zipfile

Chris Rebert clp2 at rebertia.com
Mon Nov 2 20:37:31 EST 2009


> On Mon, Nov 2, 2009 at 5:02 PM, Tim Chase <python.list at tim.thechases.com>
> wrote:
>>>> 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'
>>>
>>> ZipFile.open(name[, mode[, pwd]])
>>> [...]
>>>    New in version 2.6.
>>>
>>> Would your Python version happen to be pre-2.6?
>>
>> FWIW, you can use the 2.6 zipfile.py as far back as 2.4 by just copying it
>> into your project directory.  I had a similar issue in 2.4 (wanted the
>> iterator provided by 2.6's open() call) and Gabriel suggested trying to just
>> copy in the 2.6 version into my project directory.  Worked for me(tm).

On Mon, Nov 2, 2009 at 5:28 PM, sityee kong <skong1 at gmail.com> wrote:
> Hi all, yes, im using python 2.4.
>
> I would like to know how does python 2.4 work for my case w/o the new added
> feature in 2.6? Do you guys know?

Looks like you'd have to use the more primitive .read() method:
http://docs.python.org/library/zipfile.html#zipfile.ZipFile.read

Also, please avoid top-posting in the future.

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list