#!/usr/bin/env python # FAA_ATA100_examples/simple.py # # a simple example of using the FAA_ATA100 Python module to parse # FAA data # # Kyler Laird (Kyler@Lairds.com) # May, 2004 # # # This program uses the library file "FAA_ATA100.py". It is available # here. # http://aviationtoolbox.org/munge/FAA_ATA100.py # If it's not in your default path (such as in the current directory), # modify the system path to find it. import sys sys.path.append('../') import FAA_ATA100 # Specify the zip file containing the ATA-100 data. # Adjust the path as necessary to find the file as provided here. # http://aviationtoolbox.org/raw_data/FAA/ATA-100/current.zip FAA_data = FAA_ATA100.ATA100zip('../../raw_data/FAA/ATA-100/current.zip') # We're only going to look at APT records. # The description is here. # http://aviationtoolbox.org/old/ATA-100/Subscriber_File_Formats/Apt_rf.txt FAA_parsed_data = FAA_data.parse('APT') # Iterate through each of the record types (APT and RWY). for record_type in FAA_parsed_data.fields.keys(): print record_type # Dump the names we use for each of the fields. These names # are the first lines of the field descriptions from the # description file. for field_name in FAA_parsed_data.fields[record_type]: print '\t' + field_name # Only look at these airports. interesting_airports = ['LAF', 'BMG'] interesting_entry = 0 # Iterate over all of the APT records. for record in FAA_parsed_data: # What's the record type indicator? rti = record['RTI'] # It's an airport? if rti == 'APT': ident = record['LOCATION IDENTIFIER'] if not ident in interesting_airports: interesting_entry = 0 continue interesting_entry = 1 print ident, print record['LOCATION IDENTIFIER'], print record['ASSOCIATED CITY NAME'], print record['ASSOCIATED STATE POST OFFICE CODE'], print FAA_ATA100.seconds_to_degrees(record['AIRPORT REFERENCE POINT LONGITUDE (SECONDS)']), print FAA_ATA100.seconds_to_degrees(record['AIRPORT REFERENCE POINT LATITUDE (SECONDS)']) # This isn't an APT record and the last APT record we saw was # not for an airport of interest. elif not interesting_entry: continue # This is a runway? elif rti == 'RWY': print '\t', print record['RUNWAY IDENTIFICATION'], print record['PHYSICAL RUNWAY LENGTH (NEAREST FOOT)'], print record['PHYSICAL RUNWAY WIDTH (NEAREST FOOT)']