예제 #1
0
    for entry in list:
        if entry not in found:
            found.append(entry)
            keep.append(entry)
    return keep

with open('boroughs.csv') as f:
    rows = csv.reader(f, delimiter=',')
    for row in rows:
        thiszip = Zipcode(row[0])
        rowentry = row[1]
        if (rowentry.lower() == borough.name):
            borough.addZipcode(thiszip.number)

borough.zipcodes = makeunique(borough.zipcodes)

with open('zipCodes.csv') as f:
    rows = csv.reader(f, delimiter=',')
    rows.next()
    for row in rows:
        if (row[10] != ''):
            rowzip = row[1]
            rowpop = float(row[10].strip())
            for line in borough.zipcodes:
                if (int(rowzip) == int(line)):
                    borough.addPopulation(rowpop)


borough.findAverage()
print borough.average