Country Codes

question
package

#1

Hey All,

Just wondering if there’s an existing package that would provide a Dict mapping ISO country codes (Alpha-2 or Alpha-3) to country names and possibly ISO numeric codes as well.

Thanks!


#2

I managed to create such a Dict with:

using WorldBankData
dt = search_wdi("countries", "iso2c", r".")
iso2name = Dict([(dt[:iso2c][i], dt[:name][i]) for i in eachindex(dt[:iso2c])])

Not the most polished code, but you’d only need to run it once, then you can run show(iso2name) and copy the displayed code to a .jl-file if you want. A bit more effort would be required if you want to filter out non-country entries.


#3

Here’s the actual generated Dict with 304 entries.

Dict("V3"=>"Late-demographic dividend","A5"=>"Sub-Saharan Africa excluding South Africa and Nigeria","OM"=>"Oman","T5"=>"South Asia (IDA & IBRD)","NO"=>"Norway","DO"=>"Dominican Republic","D2"=>"Latin America & the Caribbean (IDA-eligible countries)","SR"=>"Suriname","BS"=>"Bahamas, The","XE"=>"Heavily indebted poor countries (HIPC)","NP"=>"Nepal","EG"=>"Egypt, Arab Rep.","EE"=>"Estonia","CU"=>"Cuba","US"=>"United States","LU"=>"Luxembourg","1W"=>"World","CM"=>"Cameroon","XD"=>"High income","AE"=>"United Arab Emirates","JG"=>"Channel Islands","A9"=>"Africa","FR"=>"France","FI"=>"Finland","VG"=>"British Virgin Islands","JP"=>"Japan","6X"=>"Non-resource rich Sub-Saharan Africa countries","TG"=>"Togo","GW"=>"Guinea-Bissau","IE"=>"Ireland","TV"=>"Tuvalu","MX"=>"Mexico","GY"=>"Guyana","CA"=>"Canada","AD"=>"Andorra","T6"=>"Sub-Saharan Africa (IDA & IBRD countries)","C4"=>"East Asia and the Pacific (IFC classification)","MF"=>"St. Martin (French part)","XI"=>"IDA only","VE"=>"Venezuela, RB","KN"=>"St. Kitts and Nevis","M2"=>"North Africa","6L"=>"Non-resource rich Sub-Saharan Africa countries, of which landlocked","SD"=>"Sudan","XH"=>"IDA blend","GU"=>"Guam","NE"=>"Niger","TM"=>"Turkmenistan","B6"=>"Sub-Saharan Africa (IBRD-only countries)","BN"=>"Brunei Darussalam","V2"=>"Early-demographic dividend","XL"=>"Least developed countries: UN classification","KZ"=>"Kazakhstan","CI"=>"Cote d'Ivoire","6D"=>"IDA total, excluding Sub-Saharan Africa","ZF"=>"Sub-Saharan Africa (excluding high income)","SX"=>"Sint Maarten (Dutch part)","CO"=>"Colombia","QA"=>"Qatar","Z4"=>"East Asia & Pacific","C6"=>"Latin America and the Caribbean (IFC classification)","PG"=>"Papua New Guinea","LV"=>"Latvia","UY"=>"Uruguay","RO"=>"Romania","IM"=>"Isle of Man","XC"=>"Euro area","4E"=>"East Asia & Pacific (excluding high income)","PA"=>"Panama","BI"=>"Burundi","SA"=>"Saudi Arabia","PF"=>"French Polynesia","S4"=>"Other small states","VU"=>"Vanuatu","ZT"=>"IDA & IBRD total","6N"=>"IDA countries not classified as fragile situations, excluding Sub-Saharan Africa","C5"=>"Europe and Central Asia (IFC classification)","XK"=>"Kosovo","6F"=>"IDA countries classified as fragile situations, excluding Sub-Saharan Africa","AU"=>"Australia","TR"=>"Turkey","S2"=>"Pacific island small states","GB"=>"United Kingdom","WS"=>"Samoa","GN"=>"Guinea","GT"=>"Guatemala","UA"=>"Ukraine","GA"=>"Gabon","M1"=>"Middle East (developing only)","BZ"=>"Belize","BA"=>"Bosnia and Herzegovina","B2"=>"Latin America & the Caribbean (IBRD-only countries)","KP"=>"Korea, Dem. People’s Rep.","SS"=>"South Sudan","PL"=>"Poland","D4"=>"East Asia & Pacific (IDA-eligible countries)","KI"=>"Kiribati","XP"=>"Middle income","PR"=>"Puerto Rico","XG"=>"IDA total","HR"=>"Croatia","Z7"=>"Europe & Central Asia","8S"=>"South Asia","TT"=>"Trinidad and Tobago","PE"=>"Peru","MR"=>"Mauritania","CZ"=>"Czech Republic","AG"=>"Antigua and Barbuda","BD"=>"Bangladesh","MH"=>"Marshall Islands","MT"=>"Malta","BT"=>"Bhutan","SI"=>"Slovenia","AS"=>"American Samoa","MG"=>"Madagascar","B1"=>"IBRD countries classified as high income","7E"=>"Europe & Central Asia (excluding high income)","MC"=>"Monaco","F6"=>"IDA countries in Sub-Saharan Africa classified as fragile situations ","IR"=>"Iran, Islamic Rep.","TZ"=>"Tanzania","BY"=>"Belarus","LC"=>"St. Lucia","IQ"=>"Iraq","FO"=>"Faroe Islands","O6"=>"Resource rich Sub-Saharan Africa countries, of which oil exporters","IS"=>"Iceland","BO"=>"Bolivia","ZG"=>"Sub-Saharan Africa ","T2"=>"Latin America & the Caribbean (IDA & IBRD countries)","CL"=>"Chile","CW"=>"Curacao","BJ"=>"Benin","DK"=>"Denmark","IN"=>"India","L5"=>"Andean Region","GM"=>"Gambia, The","AM"=>"Armenia","DZ"=>"Algeria","KW"=>"Kuwait","TJ"=>"Tajikistan","LK"=>"Sri Lanka","UG"=>"Uganda","ZW"=>"Zimbabwe","B7"=>"Europe & Central Asia (IBRD-only countries)","MY"=>"Malaysia","GD"=>"Grenada","ES"=>"Spain","N6"=>"IDA countries in Sub-Saharan Africa not classified as fragile situations ","SM"=>"San Marino","B8"=>"Central Europe and the Baltics","T4"=>"East Asia & Pacific (IDA & IBRD countries)","V1"=>"Pre-demographic dividend","BB"=>"Barbados","VN"=>"Vietnam","CF"=>"Central African Republic","DJ"=>"Djibouti","FJ"=>"Fiji","ST"=>"Sao Tome and Principe","NZ"=>"New Zealand","SY"=>"Syrian Arab Republic","D6"=>"Sub-Saharan Africa (IDA-eligible countries)","C7"=>"Middle East and North Africa (IFC classification)","PH"=>"Philippines","XJ"=>"Latin America & Caribbean (excluding high income)","IL"=>"Israel","XQ"=>"Middle East & North Africa (excluding high income)","KE"=>"Kenya","MW"=>"Malawi","MV"=>"Maldives","AW"=>"Aruba","D9"=>"IDA countries not classified as Fragile Situations","S1"=>"Small states","HK"=>"Hong Kong SAR, China","SZ"=>"Swaziland","ID"=>"Indonesia","AT"=>"Austria","LR"=>"Liberia","XY"=>"Not classified","SO"=>"Somalia","XO"=>"Low & middle income","MZ"=>"Mozambique","D3"=>"Middle East & North Africa (IDA-eligible countries)","R6"=>"Resource rich Sub-Saharan Africa countries","MA"=>"Morocco","XU"=>"North America","SK"=>"Slovak Republic","TW"=>"Taiwan, China","SV"=>"El Salvador","CD"=>"Congo, Dem. Rep.","EU"=>"European Union","CH"=>"Switzerland","KH"=>"Cambodia","GQ"=>"Equatorial Guinea","ZA"=>"South Africa","T3"=>"Middle East & North Africa (IDA & IBRD countries)","MO"=>"Macao SAR, China","F1"=>"Fragile and conflict affected situations","HN"=>"Honduras","SL"=>"Sierra Leone","LI"=>"Liechtenstein","IT"=>"Italy","D7"=>"Europe & Central Asia (IDA-eligible countries)","YE"=>"Yemen, Rep.","SC"=>"Seychelles","ME"=>"Montenegro","ZJ"=>"Latin America & Caribbean ","CV"=>"Cabo Verde","BE"=>"Belgium","NC"=>"New Caledonia","JO"=>"Jordan","GH"=>"Ghana","DE"=>"Germany","XM"=>"Low income","MD"=>"Moldova","B3"=>"Middle East & North Africa (IBRD-only countries)","ZB"=>"IBRD, including blend","AO"=>"Angola","TO"=>"Tonga","LT"=>"Lithuania","RU"=>"Russian Federation","L7"=>"Southern Cone","D8"=>"IDA countries classified as Fragile Situations","EC"=>"Ecuador","HT"=>"Haiti","L6"=>"Central America","SE"=>"Sweden","CG"=>"Congo, Rep.","KG"=>"Kyrgyz Republic","MN"=>"Mongolia","NG"=>"Nigeria","PS"=>"West Bank and Gaza","XN"=>"Lower middle income","MM"=>"Myanmar","ML"=>"Mali","LA"=>"Lao PDR","PK"=>"Pakistan","LB"=>"Lebanon","GR"=>"Greece","HU"=>"Hungary","RS"=>"Serbia","BF"=>"Burkina Faso","C9"=>"Sub-Saharan Africa (IFC classification)","CN"=>"China","KR"=>"Korea, Rep.","ER"=>"Eritrea","ET"=>"Ethiopia","GE"=>"Georgia","BM"=>"Bermuda","TH"=>"Thailand","SN"=>"Senegal","V4"=>"Post-demographic dividend","TD"=>"Chad","NL"=>"Netherlands","BG"=>"Bulgaria","NR"=>"Nauru","TC"=>"Turks and Caicos Islands","VI"=>"Virgin Islands (U.S.)","FM"=>"Micronesia, Fed. Sts.","A4"=>"Sub-Saharan Africa excluding South Africa","B4"=>"East Asia & Pacific (IBRD-only countries)","BH"=>"Bahrain","LS"=>"Lesotho","PW"=>"Palau","AF"=>"Afghanistan","NA"=>"Namibia","LY"=>"Libya","XF"=>"IBRD only","SB"=>"Solomon Islands","OE"=>"OECD members","PT"=>"Portugal","ZM"=>"Zambia","KY"=>"Cayman Islands","TL"=>"Timor-Leste","CR"=>"Costa Rica","PY"=>"Paraguay","RW"=>"Rwanda","AR"=>"Argentina","GL"=>"Greenland","AZ"=>"Azerbaijan","KM"=>"Comoros","VC"=>"St. Vincent and the Grenadines","BR"=>"Brazil","L4"=>"Latin America and the Caribbean","MK"=>"Macedonia, FYR","MU"=>"Mauritius","SG"=>"Singapore","MP"=>"Northern Mariana Islands","AL"=>"Albania","C8"=>"South Asia (IFC classification)","UZ"=>"Uzbekistan","T7"=>"Europe & Central Asia (IDA & IBRD countries)","1A"=>"Arab World","JM"=>"Jamaica","S3"=>"Caribbean small states","CY"=>"Cyprus","GI"=>"Gibraltar","ZQ"=>"Middle East & North Africa","TN"=>"Tunisia","DM"=>"Dominica","BW"=>"Botswana","D5"=>"South Asia (IDA-eligible countries)","XT"=>"Upper middle income","NI"=>"Nicaragua")

#4

Neat. Thanks again!


#5

I got MethodError: no method matching take!(::HTTP.Messages.Response) at WorldBankData.jl:19
on julia v0.6.
I fixed the error by replacing take!(request) by request.body, did anoyne else get this error?


#6

I did, too. You should submit a PR?