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