import csv
import zipfile
zipfname = 'test.zip'
z = zipfile.ZipFile(zipfname, 'r')
for info in z.infolist():
fname = info.filename
if fname.endswith('.csv'): # detect the .csv file
content = z.read(fname) # read the content
data = content.split('\n') # split by lines to the list
reader = csv.reader(data) # and consume by the reader
for row in reader: # iterate through the rows
print repr(row)
z.close()
|