Beispiel #1
0
dbFile.close()

# open the next file and pull relevant pop and area information into borough object
dbFile = open("zipCodes.csv", "r")
for line in dbFile:
    tempArray = line.strip().split(",")
    zipnum = tempArray[1]

    # check that this is a zipcode in the user supplied borough
    if zipnum in borough.zipcodes:
        # check that all values exist for that zip
        # check that area is valid
        if len(tempArray[7]) > 0:
            area = float(tempArray[7])
        else:
            area = 0
            # check that the zip has a defined pop
        if len(tempArray[10]) > 0:
            pop = float(tempArray[10])
        else:  # assign it to 0
            pop = 0

            # add the information to the object
        borough.modify_Pop_Area(zipnum, pop, area)

        # print "" + str(zipnum) + " " + str(area) + " " + str(pop) + " "
dbFile.close()

# print the average population
print borough.avgPopStr()