Exemple #1
0
def write_openaddresses_test(inputF, outputF, sorted_key, zips):
    output = open(outputF, 'w')
    current_inx = 0
    with open(inputF, 'r') as points:
        for point in points:
            s_point = (point.strip('\r\n')).split(',')
            if len(s_point) == 8:
                s_point.append('')
            #run function find_zip with lon and lat of current row as a point and the index of the last found point
            result = Zip_Backfill.find_zip(
                Point(float(s_point[0]), float(s_point[1])), current_inx,
                sorted_key, zips)
            #set current_inx to the index of the last point found
            current_inx = result[1]
            #if zcta zip is same as on file
            if result[0] == s_point[7]:
                s_point[8] = 'same'
                #if no zcta zip is found
            elif result[0] == 'None':
                s_point[8] = 'None'
                #if zcta is not the same as on file write in found zip
            else:
                s_point[8] = result[0]
            output.write(",".join(s_point) + '\n')
    output.close()
Exemple #2
0
def write_openaddresses_test(inputF, outputF, sorted_key, zips):
    output = open(outputF, "w")
    current_inx = 0
    with open(inputF, "r") as points:
        for point in points:
            s_point = (point.strip("\r\n")).split(",")
            if len(s_point) == 8:
                s_point.append("")
                # run function find_zip with lon and lat of current row as a point and the index of the last found point
            result = Zip_Backfill.find_zip(Point(float(s_point[0]), float(s_point[1])), current_inx, sorted_key, zips)
            # set current_inx to the index of the last point found
            current_inx = result[1]
            # if zcta zip is same as on file
            if result[0] == s_point[7]:
                s_point[8] = "same"
            # if no zcta zip is found
            elif result[0] == "None":
                s_point[8] = "None"
            # if zcta is not the same as on file write in found zip
            else:
                s_point[8] = result[0]
            output.write(",".join(s_point) + "\n")
    output.close()