Last active
February 4, 2022 17:45
-
-
Save poxrud/7782545 to your computer and use it in GitHub Desktop.
Get a comma separated list of ISO 3166 Country Codes. (example: AF,AX,AL,DZ...)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
uri = URI('https://pkgstore.datahub.io/core/country-list/data_csv/data/d7c9d7cfb42cb69f4422dec222dbbaa8/data_csv.csv') | |
countries = Net::HTTP.get(uri) | |
countries = countries.split("\r\n").drop(1) | |
countries = countries.map do |country| | |
country.split(",").last | |
end.join(",") | |
puts countries |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI, this URL is outdated: http://www.iso.org/iso/home/standards/country_codes/country_names_and_code_elements_txt.htm
I'm not sure of an alternative at the moment.