Spaces:
Runtime error
Runtime error
import pandas as pd | |
from typing import NamedTuple, Dict | |
class ZipCodeEntry(NamedTuple): | |
zip: str | |
state: str | |
lat: str | |
long: str | |
def _load_zip_codes() -> Dict[str, ZipCodeEntry]: | |
df = pd.read_csv('Map-City-State-Zip-Lat-Long.txt', dtype=str, sep=';') | |
zip_code_list = {} | |
for _, row in df.iterrows(): | |
zip_code = row.get('Zip') | |
if zip_code: | |
zip_code_entry = ZipCodeEntry( | |
zip=zip_code, | |
city=row.get('City'), | |
state=row.get('State'), | |
lat=row.get('Latitude'), | |
long=row.get('Longitude')) | |
zip_code_list[zip_code] = zip_code_entry | |
return zip_code_list | |
ZIP_CODE_LIST = _load_zip_codes() | |
print(ZIP_CODE_LIST) |