|
Function Name Description
load_airports(reader)
Given an open reader that contains airport data in the format described above this table, return a tuple that contains two dictionaries and a list.
The first dictionary should contain three-letter airport codes (of type str) as keys and tuples with two elements as values. Each tuple should contain the city the airport is associated with (str) as the first value and a tuple containing its latitude (float) and longitude (float) as the second value.
The latitude and longitude tuple should be obtained by providing the name of the airport followed by the word CANADA to the geocode function of the maps module. If the maps module cannot provide the latitude and longitude of the airport, the airport should not be placed in this dictionary.
The second dictionary should also use three-letter airport codes as keys. An airport should only be represented in this dictionary if it has US or international flights. If an airport has US flights (but no international flights), its value in the dictionary should be the str "US". If it has international flights, its value should be the str "INT". Again, if the maps module cannot provide the latitude and longitude of the airport, the airport should not be placed in this dictionary.
The list should contain the three-letter codes of all airports that the geocode function (which uses Google's geocoding service) cannot locate.
airport info is located here. its supposed to be part of a .txt file called small_airports.txt
DEER LAKE:YDF:DEER LAKE
EDMONTON INTERNATIONAL:YEG:EDMONTON:US
FREDERICTON:YFC:FREDERICTON
HALIFAX INTERNATIONAL:YHZ:HALIFAX:INT
MONTREAL INTERNATIONAL MIRABEL:YMX:MONTREAL:INT
OLD CROW:YOC:OLD CROW
WINDSOR:YQG:WINDSOR
REGINA INTERNATIONAL:YQR:REGINA:US
THUNDER BAY:YQT:THUNDER BAY
VANCOUVER INTERNATIONAL:YVR:VANCOUVER:INT
MONT JOLI:YYY:MONT JOLI
LESTER B PEARSON INTERNATIONAL:YYZ:TORONTO:INT
My question is the following: How do i take this .txt file, split the parts, and put these separate elements into the appropriate lists and dictionaries, etc. The latitude and Longitude tuple can't be completed unless you have the program for it, so dont worry about that part. Thanks a bunch!
|