Skip to content

Instantly share code, notes, and snippets.

Last active Nov 27, 2016
What would you like to do?
Batteries included: Download, unzip and parse in 13 lines -
import zipfile, urllib, csv, os, codecs
def get_items(url):
filename, headers = urllib.urlretrieve(url)
with zipfile.ZipFile(filename) as zf:
csvfiles = [name for name in zf.namelist()
if name.endswith('.csv')]
for item in csvfiles:
with as source:
reader = csv.DictReader(codecs.getreader('iso-8859-1')(source))
for line in reader:
yield line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment