Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
-
import
|
| 2 |
-
import pandas as
|
| 3 |
from typing import NamedTuple, Dict
|
| 4 |
|
|
|
|
| 5 |
class ZipCodeEntry(NamedTuple):
|
| 6 |
zip: str
|
| 7 |
city: str
|
|
@@ -9,9 +10,11 @@ class ZipCodeEntry(NamedTuple):
|
|
| 9 |
lat: str
|
| 10 |
long: str
|
| 11 |
|
|
|
|
| 12 |
def _load_zip_codes() -> Dict[str, ZipCodeEntry]:
|
| 13 |
-
df =
|
| 14 |
zip_code_list = {}
|
|
|
|
| 15 |
for _, row in df.iterrows():
|
| 16 |
zip_code = row.get('Zip')
|
| 17 |
if zip_code:
|
|
@@ -22,7 +25,13 @@ def _load_zip_codes() -> Dict[str, ZipCodeEntry]:
|
|
| 22 |
lat=row.get('Latitude'),
|
| 23 |
long=row.get('Longitude'))
|
| 24 |
zip_code_list[zip_code] = zip_code_entry
|
|
|
|
| 25 |
return zip_code_list
|
| 26 |
|
|
|
|
| 27 |
ZIP_CODE_LIST = _load_zip_codes()
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import definitions
|
| 2 |
+
import pandas as pdb
|
| 3 |
from typing import NamedTuple, Dict
|
| 4 |
|
| 5 |
+
|
| 6 |
class ZipCodeEntry(NamedTuple):
|
| 7 |
zip: str
|
| 8 |
city: str
|
|
|
|
| 10 |
lat: str
|
| 11 |
long: str
|
| 12 |
|
| 13 |
+
|
| 14 |
def _load_zip_codes() -> Dict[str, ZipCodeEntry]:
|
| 15 |
+
df = pdb.read_csv('Map-City-State-Zip-Lat-Long.txt', dtype=str,sep=';')
|
| 16 |
zip_code_list = {}
|
| 17 |
+
# Zip;City;State;Latitude;Longitude;Timezone;
|
| 18 |
for _, row in df.iterrows():
|
| 19 |
zip_code = row.get('Zip')
|
| 20 |
if zip_code:
|
|
|
|
| 25 |
lat=row.get('Latitude'),
|
| 26 |
long=row.get('Longitude'))
|
| 27 |
zip_code_list[zip_code] = zip_code_entry
|
| 28 |
+
|
| 29 |
return zip_code_list
|
| 30 |
|
| 31 |
+
|
| 32 |
ZIP_CODE_LIST = _load_zip_codes()
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
if __name__ == '__main__':
|
| 36 |
+
print(ZIP_CODE_LIST)
|
| 37 |
+
print(ZIP_CODE_LIST.get('62833'))
|