File size: 911 Bytes
d863e72
e133ffb
5dcdc61
 
e133ffb
5dcdc61
 
43ce9e3
5dcdc61
 
 
 
e133ffb
5dcdc61
e133ffb
5dcdc61
e133ffb
5dcdc61
 
 
 
 
 
 
 
c53bec7
5dcdc61
e133ffb
5dcdc61
 
e133ffb
c53bec7
e133ffb
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#import definitions
import pandas as pdb
from typing import NamedTuple, Dict


class ZipCodeEntry(NamedTuple):
    zip: str
    city: str
    state: str
    lat: str
    long: str


def _load_zip_codes() -> Dict[str, ZipCodeEntry]:
    df = pdb.read_csv('Map-City-State-Zip-Lat-Long.txt', dtype=str,sep=';')
    zip_code_list = {}
    # Zip;City;State;Latitude;Longitude;Timezone;
    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()


if __name__ == '__main__':
    print(ZIP_CODE_LIST)
    print(ZIP_CODE_LIST.get('62833'))