[CentralOH] Improving Zipfile Code

jep200404 at columbus.rr.com jep200404 at columbus.rr.com
Mon Oct 22 04:46:15 CEST 2012

The following code smells. How would you improve it? 

import csv
from zipfile import ZipFile

def foo(filename):
    z = ZipFile(filename)
    for f in filter((lambda s: s.endswith('.xyz')), z.namelist()):
        for line_number, row in enumerate(csv.DictReader(z.open(f, 'rU')), 2):
            print 'line_number:', line_number, 'row:', row

More information about the CentralOH mailing list