def loadStationsFile()

in noaa/_tools/process.py [0:0]


def loadStationsFile(stationsFile, statesFile, countriesFile):
    statesMap = loadStatesFile(statesFile)
    countriesMap = loadCountriesFile(countriesFile)
    stationsMap = {}
    with open(stationsFile, 'r') as file:
        for row in file:
            try:
                station = {}
                station['id'] = row[0:11].strip()
                countryCode = row[0:2].strip()
                if len(countryCode) > 0:
                    station['country_code'] = countryCode
                    station['country'] = countriesMap[countryCode]
                station['location'] = {
                    'lat': float(row[12:20].strip()),
                    'lon': float(row[21:30].strip())
                }
                station['elevation'] = float(row[31:37].strip())
                if countryCode == 'US':
                    stateCode = row[38:40].strip()
                    if len(stateCode) > 0:
                        station['state_code'] = stateCode
                        station['state'] = statesMap[stateCode]
                station['name'] = row[41:71].strip()
                gsn_flag = row[72:75].strip()
                if len(gsn_flag) > 0:
                    station['gsn_flag'] = gsn_flag
                hcn_crn_flag = row[76:78].strip()
                if len(hcn_crn_flag) > 0:
                    station['hcn_crn_flag'] = hcn_crn_flag
                wmo_id = row[80:85].strip()
                if len(wmo_id) > 0:
                    station['wmo_id'] = wmo_id
                stationsMap[station['id']] = station
            except:
                print(row)
                raise e
    return stationsMap