Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ods94065
Created January 22, 2015 04:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ods94065/e8bb54570d170e97b19b to your computer and use it in GitHub Desktop.
Save ods94065/e8bb54570d170e97b19b to your computer and use it in GitHub Desktop.
Using StringIO to read a zip file directly from the network
import urllib2
import zipfile
import StringIO
response = urllib2.urlopen('http://some_url.zip')
body = response.read()
io = StringIO.StringIO(body)
# io is a file-like object... you can use it where you'd use a file!
myfile = zipfile.ZipFile(io)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment