Free IATA + ICAO airport codes database

Parsed from: Wikipedia.

Available on YAML or JSON format.

Data example:

- :airport_name: Charles de Gaulle International Airport (Roissy Airport)
  :complete_location: Paris, France
  :city: Paris
  :country: "France"
  :iata_code: CDG
  :icao_code: LFPG

Below is a snippet on how to parse this content using Hpricot.

        doc = Hpricot(open "{letter}")'table.wikitable tr:not(:first-child):not(.sortbottom)').each do |tr_line|
          # Iata, Icao, Airport name, Location served
          line_records = (tr_line/'td').map{|el| ActionController::Base.helpers.strip_tags el.inner_html}
          next if line_records[2].blank?
          airport = {:iata_code         => line_records[0],
                     :icao_code         => line_records[1],
                     :airport_name      => line_records[2],
                     :complete_location => line_records[3],

          location_array = airport[:complete_location].split(',')
          unless location_array.blank?
            airport[:city]    = location_array.first
            airport[:country] = location_array.last

          result << airport

One Response

  1. Hello Vlad-Ionut Zloteanu

    When i tried to parse the above JSON string in PHP , i got the error saying
    “- Syntax error, malformed JSON”.

    Could you please help me to resolve this?

    Thanks in Advance !!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: