title: Python: get zip file from url, extract, and save files / images to server
body: <p>I am getting a zipfile from a url.</p>
  
  <p>Extracted, it has the following format:</p>
  
  <ul>
  <li>parent_folder
  <ul>
  <li>my_file.csv</li>
  <li>image_folder
  <ul>
  <li>my_image.jpg</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>I want to save this, extracted, to my server. Before saving, I want to 1) alter the name of parent_folder and 2) insert extra text into the .csv file</p>
  
  <p>I have tried various combinations of code trying to figure out what is going on:</p>
  
  <pre><code>from StringIO import StringIO
  from zipfile import ZipFile
  from urllib import urlopen
  from PIL import Image
  
  url = urlopen("path.zip")
  z = ZipFile(StringIO(url.read()))
  
  # z= z.extractall() # not sure I need this?
  
  for line in z.open("my_file.csv").readlines():
       print line  
       # this does print so I could open a new file and write to it. Is that what I do?
  
  img= Image.open(cStringIO.StringIO(z.open("image_folder/my_image.jpg")))
  # error: must be convertible to a buffer, not ZipExtFile
  # I don't know how to GET the image
  </code></pre>