#! /usr/bin/env ruby # Codes for the representation of names of languages (Library of Congress) # http://www.loc.gov/standards/iso639-2/ascii_8bits.html require 'open-uri' require 'yaml' url = 'http://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt' table = [] open(url) do |io| io.each_line do |line| table << line.chomp.split('|') end end iso639_1 = table.select { |r| !r[2].empty? } puts iso639_1.map { |r| "#{r[2]}\t#{r[3]}" } # puts YAML::dump(Hash[iso639_1.map { |r| [r[2], r[3]] }])