Objective: I am trying to compute distance between all zip codes, but only include those that are 25 miles or less apart.
Problem: The way I think the code should work is pull a zip code using a loop, and then with another loop pull another zip code. The problem is, if zip1 = XXX, it only grabs pairs that start with XXX and fails to then move to YYY for zip1 once it has iterated over all the combinations.
for line in f_in:
zip1 = line["ZIP"]
lat = line["LAT"]
lon = line["LNG"]
loc = (float(lat),float(lon))
for entry in b_in:
zip2 = entry["ZIP"]
lat2 = entry["LAT"]
lon2 = entry["LNG"]
loc2 = (float(lat2),float(lon2))
combzip = str(zip1)+str(zip2)
print combzip
if not ziplist.has_key(combzip):
dist = haversine.haversine(loc,loc2,miles=True)
if dist > 20:
continue
ziplist[combzip] = [zip1,zip2,dist]