Christopher Culver wrote:
Tino Wildenhain <t...@wildenhain.de> writes:
so instead you would use archive = zipfile.ZipFile(remotedata)
That produces the following error if I try that in the Python
interpreter (URL edited for privacy): ....
remotedata = urllib2.urlopen("http://...file.zip";)
archive = zipfile.ZipFile(remotedata)

No, he means you need to pull down the remote data.  Zip  file reading
is not done in a single pass; it needs to seek to find the directory,
then again to get to the data for any particular file.  Seeking around
a file does not work so well across the net.

Try something like:
    >>> import zipfile
    >>> import urllib2
    >>> import StringIO # or cStringIO as StringIO
    >>> remotehandle = urllib2.urlopen("http://...file.zip";)
    >>> zipdata = StringIO.StringIO(remotehandle.read())
    >>> remotehandle.close()
    >>> archive = zipfile.ZipFile(zipdata)
or:
    >>> with urllib2.urlopen("http://...file.zip";) as remotehandle:
    ...    zipdata = StringIO.StringIO(remotehandle.read())
    ...    archive = zipfile.ZipFile(zipdata)

--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to