Pretty simple here, I\'m looking for a lightweight library that will allow me to lookup a city/state pairing for a given zip code. I am using django FWIW. Thanks in advance.>
Use this library uszipcode.
Advantages:
zipcode
and pyzipcode
and any other python zipcode library.>>> from uszipcode import ZipcodeSearchEngine
>>> search = ZipcodeSearchEngine()
>>> zipcode = search.by_zipcode("10001")
>>> print(zipcode)
{
"City": "New York",
"Density": 34035.48387096774,
"HouseOfUnits": 12476,
"LandArea": 0.62,
"Latitude": 40.75368539999999,
"Longitude": -73.9991637,
"NEBoundLatitude": 40.8282129,
"NEBoundLongitude": -73.9321059,
"Population": 21102,
"SWBoundLatitude": 40.743451,
"SWBoungLongitude": -74.00794499999998,
"State": "NY",
"TotalWages": 1031960117.0,
"WaterArea": 0.0,
"Wealthy": 48903.42702113544,
"Zipcode": "10001",
"ZipcodeType": "Standard"
}
# fuzzy city, state search, case insensitive, spelling mistake tolerant
# all zipcode in new york
>>> result = search.by_city_and_state(city="newyork", state="NY")
>>> search.export_to_csv(result, "result.csv")
Very easy to use to build advance search
>>> result = search.find(city="new york",
... wealthy=100000, sort_by="Wealthy", ascending=False, returns=10)