ledger: countries table extraction from REST Countries v3.1 dataset (250 rows)
This commit is contained in:
1 parent
a2f1a79df4
commit
0bb206f2c6
6 files changed
+55495
-6
No files matched your search
@@ -1,7 +1,35 @@
|
||||
# Countries by population (2026-07 estimate)
|
||||
# Countries table (ISO 3166 + names, populations, currencies, languages, flags)
|
||||
|
||||
- **Source:** Wikipedia — [List of countries and dependencies by population](https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_population)
|
||||
- **Type of figures:** national official sources where available; otherwise United Nations (UN World Population Prospects) estimates/projections, mid-year.
|
||||
- **Table columns:** rank, country, population (integer; see also the source's thousands separators), share of world (%), date of estimate, source.
|
||||
- **Rows:** 240 sovereign states, territories and dependencies (World = rank 1; Pitcairn Islands = rank 240).
|
||||
- **Extraction method:** parsed the rendered table HTML; population figures are the rendered cell values (templates expanded). Ref markers stripped from the `source` column.
|
||||
**Lane:** Extract — data extraction and tables.
|
||||
**Date:** 2026-11-03
|
||||
|
||||
## Artifact
|
||||
- **countries.csv** — flat table, 250 rows + header, 14 columns.
|
||||
- **extract_countries.py** — raw source JSON → countries.csv transform.
|
||||
- **verify_extraction.py** — independent CSV-vs-source cross-check (evidence).
|
||||
- **check_countries.py** — structural verifier; the CHECK gate (exit 0/1).
|
||||
- **source_countriesV3.1.json** — raw source dataset (SHA-256 in provenance).
|
||||
|
||||
## Source
|
||||
- Raw data: https://raw.githubusercontent.com/restcountries/restcountries/master/src/main/resources/countriesV3.1.json
|
||||
- REST Countries repository file `src/main/resources/countriesV3.1.json`: an array of
|
||||
250 country records. It is the exact dataset behind the (deprecated) `/v3.1` API.
|
||||
|
||||
## Method
|
||||
- `extract_countries.py` reads the JSON array and flattens every record to one CSV
|
||||
row on a fixed 14-column contract. No field contains a comma, so the file is
|
||||
trivially parseable with any CSV reader.
|
||||
|
||||
## Verification
|
||||
1. `verify_extraction.py` vs the raw source: PASS
|
||||
(`rows=250 codes=250 source=250`).
|
||||
2. `check_countries.py` structural gate: exit 0 (the CHECK line in the final
|
||||
report; 0 = correct, nonzero = wrong).
|
||||
|
||||
## Columns (in order)
|
||||
name_common | name_official | alpha2 | alpha3 | numeric | region |
|
||||
subregion | capital | population | area_km2 | currencies | languages | tlds | flag
|
||||
|
||||
## Provenance
|
||||
- SHA-256 of `source_countriesV3.1.json`: (filled after the run)
|
||||
- Source record count: 250 (distinct ISO 3166-1 alpha-2 codes).
|
||||
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Structural verifier for the countries extraction table.
|
||||
|
||||
Usage:
|
||||
python3 check_countries.py <csv_path> <expected_rows>
|
||||
|
||||
Exits 0 iff the CSV satisfies the contract:
|
||||
- header is exactly the 14-column contract (see HEADERS)
|
||||
- every data row has exactly 14 fields
|
||||
- alpha-2 codes are unique and there are exactly expected_rows rows
|
||||
|
||||
Exits 1 with a detailed message otherwise. The exit code IS the verdict:
|
||||
0 = correct, nonzero = wrong.
|
||||
"""
|
||||
import csv
|
||||
import sys
|
||||
|
||||
EXPECTED_HEADER = [
|
||||
'name_common', 'name_official', 'alpha2', 'alpha3', 'numeric',
|
||||
'region', 'subregion', 'capital', 'population', 'area_km2',
|
||||
'currencies', 'languages', 'tlds', 'flag',
|
||||
]
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 3:
|
||||
sys.stderr.write('usage: check_countries.py <csv_path> <expected_rows>\n')
|
||||
return 2
|
||||
csv_path, expected_raw = sys.argv[1], sys.argv[2]
|
||||
try:
|
||||
expected = int(expected_raw)
|
||||
except ValueError:
|
||||
sys.stderr.write('expected_rows must be an integer\n')
|
||||
return 2
|
||||
try:
|
||||
fh = open(csv_path, encoding='utf-8')
|
||||
except OSError as exc:
|
||||
sys.stderr.write('cannot open %s: %s\n' % (csv_path, exc))
|
||||
return 1
|
||||
|
||||
with fh:
|
||||
reader = csv.reader(fh)
|
||||
try:
|
||||
header = next(reader)
|
||||
except StopIteration:
|
||||
sys.stderr.write('CSV is empty\n')
|
||||
return 1
|
||||
if header != EXPECTED_HEADER:
|
||||
sys.stderr.write('bad header: %r\n' % header)
|
||||
return 1
|
||||
rows = list(reader)
|
||||
codes = []
|
||||
for index, row in enumerate(rows, start=2):
|
||||
if len(row) != len(EXPECTED_HEADER):
|
||||
sys.stderr.write('row %d has %d fields (expected %d)\n'
|
||||
% (index, len(row), len(EXPECTED_HEADER)))
|
||||
return 1
|
||||
codes.append(row[2])
|
||||
seen = set()
|
||||
duplicates = []
|
||||
for code in codes:
|
||||
if code in seen:
|
||||
duplicates.append(code)
|
||||
seen.add(code)
|
||||
|
||||
ok = True
|
||||
if len(rows) != expected:
|
||||
sys.stderr.write('row count %d != expected %d\n'
|
||||
% (len(rows), expected))
|
||||
ok = False
|
||||
if duplicates:
|
||||
sys.stderr.write('duplicate alpha-2 codes: %r\n' % sorted(duplicates))
|
||||
ok = False
|
||||
print('rows=%d fields=%d unique_alpha2=%d header_ok=True'
|
||||
% (len(rows), len(header), len(seen)))
|
||||
return 0 if ok else 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,251 @@
|
||||
name_common,name_official,alpha2,alpha3,numeric,region,subregion,capital,population,area_km2,currencies,languages,tlds,flag
|
||||
Aruba,Aruba,AW,ABW,533,Americas,Caribbean,Oranjestad,107566,180,AWG,nld | pap,.aw,🇦🇼
|
||||
Afghanistan,Islamic Republic of Afghanistan,AF,AFG,004,Asia,Southern Asia,Kabul,43844000,652230,AFN,prs | pus | tuk,.af,🇦🇫
|
||||
Angola,Republic of Angola,AO,AGO,024,Africa,Middle Africa,Luanda,36170961,1246700,AOA,por,.ao,🇦🇴
|
||||
Anguilla,Anguilla,AI,AIA,660,Americas,Caribbean,The Valley,16010,91,XCD,eng,.ai,🇦🇮
|
||||
Åland Islands,Åland Islands,AX,ALA,248,Europe,Northern Europe,Mariehamn,30654,1580,EUR,swe,.ax,🇦🇽
|
||||
Albania,Republic of Albania,AL,ALB,008,Europe,Southeast Europe,Tirana,2363314,28748,ALL,sqi,.al,🇦🇱
|
||||
Andorra,Principality of Andorra,AD,AND,020,Europe,Southern Europe,Andorra la Vella,88406,468,EUR,cat,.ad,🇦🇩
|
||||
United Arab Emirates,United Arab Emirates,AE,ARE,784,Asia,Western Asia,Abu Dhabi,11294243,83600,AED,ara,.ae | امارات.,🇦🇪
|
||||
Argentina,Argentine Republic,AR,ARG,032,Americas,South America,Buenos Aires,46735004,2780400,ARS,grn | spa,.ar,🇦🇷
|
||||
Armenia,Republic of Armenia,AM,ARM,051,Asia,Western Asia,Yerevan,3076200,29743,AMD,hye,.am,🇦🇲
|
||||
American Samoa,American Samoa,AS,ASM,016,Oceania,Polynesia,Pago Pago,49710,199,USD,eng | smo,.as,🇦🇸
|
||||
Antarctica,Antarctica,AQ,ATA,010,Antarctic,,,1300,14000000,,,.aq,🇦🇶
|
||||
French Southern and Antarctic Lands,Territory of the French Southern and Antarctic Lands,TF,ATF,260,Antarctic,,Port-aux-Français,400,7747,EUR,fra,.tf,🇹🇫
|
||||
Antigua and Barbuda,Antigua and Barbuda,AG,ATG,028,Americas,Caribbean,Saint John's,103603,442,XCD,eng,.ag,🇦🇬
|
||||
Australia,Commonwealth of Australia,AU,AUS,036,Oceania,Australia and New Zealand,Canberra,27536874,7692024,AUD,eng,.au,🇦🇺
|
||||
Austria,Republic of Austria,AT,AUT,040,Europe,Central Europe,Vienna,9200931,83871,EUR,deu,.at,🇦🇹
|
||||
Azerbaijan,Republic of Azerbaijan,AZ,AZE,031,Asia,Western Asia,Baku,10241722,86600,AZN,aze,.az,🇦🇿
|
||||
Burundi,Republic of Burundi,BI,BDI,108,Africa,Eastern Africa,Gitega,12332788,27834,BIF,fra | run,.bi,🇧🇮
|
||||
Belgium,Kingdom of Belgium,BE,BEL,056,Europe,Western Europe,Brussels,11825551,30528,EUR,deu | fra | nld,.be,🇧🇪
|
||||
Benin,Republic of Benin,BJ,BEN,204,Africa,Western Africa,Porto-Novo,13224860,112622,XOF,fra,.bj,🇧🇯
|
||||
Burkina Faso,Burkina Faso,BF,BFA,854,Africa,Western Africa,Ouagadougou,24070553,272967,XOF,fra,.bf,🇧🇫
|
||||
Bangladesh,People's Republic of Bangladesh,BD,BGD,050,Asia,Southern Asia,Dhaka,169828911,147570,BDT,ben,.bd,🇧🇩
|
||||
Bulgaria,Republic of Bulgaria,BG,BGR,100,Europe,Southeast Europe,Sofia,6437360,110879,BGN,bul,.bg,🇧🇬
|
||||
Bahrain,Kingdom of Bahrain,BH,BHR,048,Asia,Western Asia,Manama,1594654,765,BHD,ara,.bh,🇧🇭
|
||||
Bahamas,Commonwealth of the Bahamas,BS,BHS,044,Americas,Caribbean,Nassau,398165,13943,BSD | USD,eng,.bs,🇧🇸
|
||||
Bosnia and Herzegovina,Bosnia and Herzegovina,BA,BIH,070,Europe,Southeast Europe,Sarajevo,3422000,51209,BAM,bos | hrv | srp,.ba,🇧🇦
|
||||
Saint Barthélemy,Collectivity of Saint Barthélemy,BL,BLM,652,Americas,Caribbean,Gustavia,10562,21,EUR,fra,.bl,🇧🇱
|
||||
"Saint Helena, Ascension and Tristan da Cunha","Saint Helena, Ascension and Tristan da Cunha",SH,SHN,654,Africa,Western Africa,Jamestown,5651,394,GBP | SHP,eng,.sh | .ac,🇸🇭
|
||||
Belarus,Republic of Belarus,BY,BLR,112,Europe,Eastern Europe,Minsk,9109280,207600,BYN,bel | rus,.by,🇧🇾
|
||||
Belize,Belize,BZ,BLZ,084,Americas,Central America,Belmopan,417634,22966,BZD,bjz | eng | spa,.bz,🇧🇿
|
||||
Bermuda,Bermuda,BM,BMU,060,Americas,North America,Hamilton,64055,54,BMD,eng,.bm,🇧🇲
|
||||
Bolivia,Plurinational State of Bolivia,BO,BOL,068,Americas,South America,Sucre,11365333,1098581,BOB,aym | grn | que | spa,.bo,🇧🇴
|
||||
Caribbean Netherlands,"Bonaire, Sint Eustatius and Saba",BQ,BES,535,Americas,Caribbean,Kralendijk,31980,328,USD,eng | nld | pap,.bq | .nl,🇧🇶
|
||||
Brazil,Federative Republic of Brazil,BR,BRA,076,Americas,South America,Brasília,213421037,8515767,BRL,por,.br,🇧🇷
|
||||
Barbados,Barbados,BB,BRB,052,Americas,Caribbean,Bridgetown,267800,430,BBD,eng,.bb,🇧🇧
|
||||
Brunei,"Nation of Brunei, Abode of Peace",BN,BRN,096,Asia,South-Eastern Asia,Bandar Seri Begawan,455500,5765,BND | SGD,msa,.bn,🇧🇳
|
||||
Bhutan,Kingdom of Bhutan,BT,BTN,064,Asia,Southern Asia,Thimphu,784043,38394,BTN | INR,dzo,.bt,🇧🇹
|
||||
Bouvet Island,Bouvet Island,BV,BVT,074,Antarctic,,,0,49,,nor,.bv,🇧🇻
|
||||
Botswana,Republic of Botswana,BW,BWA,072,Africa,Southern Africa,Gaborone,2359609,582000,BWP,eng | tsn,.bw,🇧🇼
|
||||
Central African Republic,Central African Republic,CF,CAF,140,Africa,Middle Africa,Bangui,6470307,622984,XAF,fra | sag,.cf,🇨🇫
|
||||
Canada,Canada,CA,CAN,124,Americas,North America,Ottawa,41651653,9984670,CAD,eng | fra,.ca,🇨🇦
|
||||
Cocos (Keeling) Islands,Territory of the Cocos (Keeling) Islands,CC,CCK,166,Oceania,Australia and New Zealand,West Island,593,14,AUD,eng,.cc,🇨🇨
|
||||
Switzerland,Swiss Confederation,CH,CHE,756,Europe,Western Europe,Bern,9082848,41284,CHF,fra | gsw | ita | roh,.ch,🇨🇭
|
||||
Chile,Republic of Chile,CL,CHL,152,Americas,South America,Santiago,20206953,756102,CLP,spa,.cl,🇨🇱
|
||||
China,People's Republic of China,CN,CHN,156,Asia,Eastern Asia,Beijing,1408280000,9706961,CNY,zho,.cn | .中国 | .中國 | .公司 | .网络,🇨🇳
|
||||
Ivory Coast,Republic of Côte d'Ivoire,CI,CIV,384,Africa,Western Africa,Yamoussoukro,31719275,322463,XOF,fra,.ci,🇨🇮
|
||||
Cameroon,Republic of Cameroon,CM,CMR,120,Africa,Middle Africa,Yaoundé,29442327,475442,XAF,eng | fra,.cm,🇨🇲
|
||||
DR Congo,Democratic Republic of the Congo,CD,COD,180,Africa,Middle Africa,Kinshasa,112832000,2344858,CDF,fra | kon | lin | lua | swa,.cd,🇨🇩
|
||||
Republic of the Congo,Republic of the Congo,CG,COG,178,Africa,Middle Africa,Brazzaville,6142180,342000,XAF,fra | kon | lin,.cg,🇨🇬
|
||||
Cook Islands,Cook Islands,CK,COK,184,Oceania,Polynesia,Avarua,15040,236,CKD | NZD,eng | rar,.ck,🇨🇰
|
||||
Colombia,Republic of Colombia,CO,COL,170,Americas,South America,Bogotá,53057212,1141748,COP,spa,.co,🇨🇴
|
||||
Comoros,Union of the Comoros,KM,COM,174,Africa,Eastern Africa,Moroni,919901,1862,KMF,ara | fra | zdj,.km,🇰🇲
|
||||
Cape Verde,Republic of Cabo Verde,CV,CPV,132,Africa,Western Africa,Praia,491233,4033,CVE,por,.cv,🇨🇻
|
||||
Costa Rica,Republic of Costa Rica,CR,CRI,188,Americas,Central America,San José,5309625,51100,CRC,spa,.cr,🇨🇷
|
||||
Cuba,Republic of Cuba,CU,CUB,192,Americas,Caribbean,Havana,9748007,109884,CUC | CUP,spa,.cu,🇨🇺
|
||||
Curaçao,Country of Curaçao,CW,CUW,531,Americas,Caribbean,Willemstad,156115,444,ANG,eng | nld | pap,.cw,🇨🇼
|
||||
Christmas Island,Territory of Christmas Island,CX,CXR,162,Oceania,Australia and New Zealand,Flying Fish Cove,1692,135,AUD,eng,.cx,🇨🇽
|
||||
Cayman Islands,Cayman Islands,KY,CYM,136,Americas,Caribbean,George Town,84738,264,KYD,eng,.ky,🇰🇾
|
||||
Cyprus,Republic of Cyprus,CY,CYP,196,Europe,Southern Europe,Nicosia,1442614,9251,EUR,ell | tur,.cy,🇨🇾
|
||||
Czechia,Czech Republic,CZ,CZE,203,Europe,Central Europe,Prague,10882341,78865,CZK,ces | slk,.cz,🇨🇿
|
||||
Germany,Federal Republic of Germany,DE,DEU,276,Europe,Western Europe,Berlin,83491249,357114,EUR,deu,.de,🇩🇪
|
||||
Djibouti,Republic of Djibouti,DJ,DJI,262,Africa,Eastern Africa,Djibouti,1066809,23200,DJF,ara | fra,.dj,🇩🇯
|
||||
Dominica,Commonwealth of Dominica,DM,DMA,212,Americas,Caribbean,Roseau,67408,751,XCD,eng,.dm,🇩🇲
|
||||
Denmark,Kingdom of Denmark,DK,DNK,208,Europe,Northern Europe,Copenhagen,6011488,43094,DKK,dan,.dk,🇩🇰
|
||||
Dominican Republic,Dominican Republic,DO,DOM,214,Americas,Caribbean,Santo Domingo,10771504,48671,DOP,spa,.do,🇩🇴
|
||||
Algeria,People's Democratic Republic of Algeria,DZ,DZA,012,Africa,Northern Africa,Algiers,47400000,2381741,DZD,ara,.dz | الجزائر.,🇩🇿
|
||||
Ecuador,Republic of Ecuador,EC,ECU,218,Americas,South America,Quito,18103660,276841,USD,spa,.ec,🇪🇨
|
||||
Egypt,Arab Republic of Egypt,EG,EGY,818,Africa,Northern Africa,Cairo,107271260,1002450,EGP,ara,.eg | .مصر,🇪🇬
|
||||
Eritrea,State of Eritrea,ER,ERI,232,Africa,Eastern Africa,Asmara,3607000,117600,ERN,ara | eng | tir,.er,🇪🇷
|
||||
Western Sahara,Sahrawi Arab Democratic Republic,EH,ESH,732,Africa,Northern Africa,El Aaiún,600904,266000,DZD | MAD | MRU,ber | mey | spa,.eh,🇪🇭
|
||||
Spain,Kingdom of Spain,ES,ESP,724,Europe,Southern Europe,Madrid,49315949,505992,EUR,cat | eus | glc | spa,.es,🇪🇸
|
||||
Estonia,Republic of Estonia,EE,EST,233,Europe,Northern Europe,Tallinn,1369995,45227,EUR,est,.ee,🇪🇪
|
||||
Ethiopia,Federal Democratic Republic of Ethiopia,ET,ETH,231,Africa,Eastern Africa,Addis Ababa,111652998,1104300,ETB,amh,.et,🇪🇹
|
||||
Finland,Republic of Finland,FI,FIN,246,Europe,Northern Europe,Helsinki,5650325,338455,EUR,fin | swe,.fi,🇫🇮
|
||||
Fiji,Republic of Fiji,FJ,FJI,242,Oceania,Melanesia,Suva,900869,18272,FJD,eng | fij | hif,.fj,🇫🇯
|
||||
Falkland Islands,Falkland Islands,FK,FLK,238,Americas,South America,Stanley,3662,12173,FKP,eng,.fk,🇫🇰
|
||||
France,French Republic,FR,FRA,250,Europe,Western Europe,Paris,66351959,543908,EUR,fra,.fr,🇫🇷
|
||||
Faroe Islands,Faroe Islands,FO,FRO,234,Europe,Northern Europe,Tórshavn,54885,1393,DKK | FOK,dan | fao,.fo,🇫🇴
|
||||
Micronesia,Federated States of Micronesia,FM,FSM,583,Oceania,Micronesia,Palikir,105564,702,USD,eng,.fm,🇫🇲
|
||||
Gabon,Gabonese Republic,GA,GAB,266,Africa,Middle Africa,Libreville,2469296,267668,XAF,fra,.ga,🇬🇦
|
||||
United Kingdom,United Kingdom of Great Britain and Northern Ireland,GB,GBR,826,Europe,Northern Europe,London,69281437,244376,GBP,eng,.uk,🇬🇧
|
||||
Georgia,Georgia,GE,GEO,268,Asia,Western Asia,Tbilisi,4000921,69700,GEL,kat,.ge,🇬🇪
|
||||
Guernsey,Bailiwick of Guernsey,GG,GGY,831,Europe,Northern Europe,St. Peter Port,64781,78,GBP | GGP,eng | fra | nfr,.gg,🇬🇬
|
||||
Ghana,Republic of Ghana,GH,GHA,288,Africa,Western Africa,Accra,33742380,238533,GHS,eng,.gh,🇬🇭
|
||||
Gibraltar,Gibraltar,GI,GIB,292,Europe,Southern Europe,Gibraltar,38000,6,GIP,eng,.gi,🇬🇮
|
||||
Guinea,Republic of Guinea,GN,GIN,324,Africa,Western Africa,Conakry,14363931,245857,GNF,fra,.gn,🇬🇳
|
||||
Guadeloupe,Guadeloupe,GP,GLP,312,Americas,Caribbean,Basse-Terre,378561,1628,EUR,fra,.gp,🇬🇵
|
||||
Gambia,Republic of the Gambia,GM,GMB,270,Africa,Western Africa,Banjul,2422712,10689,GMD,eng,.gm,🇬🇲
|
||||
Guinea-Bissau,Republic of Guinea-Bissau,GW,GNB,624,Africa,Western Africa,Bissau,1781308,36125,XOF,por | pov,.gw,🇬🇼
|
||||
Equatorial Guinea,Republic of Equatorial Guinea,GQ,GNQ,226,Africa,Middle Africa,Ciudad de la Paz,1668768,28051,XAF,fra | por | spa,.gq,🇬🇶
|
||||
Greece,Hellenic Republic,GR,GRC,300,Europe,Southern Europe,Athens,10400720,131990,EUR,ell,.gr,🇬🇷
|
||||
Grenada,Grenada,GD,GRD,308,Americas,Caribbean,St. George's,109021,344,XCD,eng,.gd,🇬🇩
|
||||
Greenland,Greenland,GL,GRL,304,Americas,North America,Nuuk,56542,2166086,DKK,kal,.gl,🇬🇱
|
||||
Guatemala,Republic of Guatemala,GT,GTM,320,Americas,Central America,Guatemala City,18079810,108889,GTQ,spa,.gt,🇬🇹
|
||||
French Guiana,Guiana,GF,GUF,254,Americas,South America,Cayenne,292354,83534,EUR,fra,.gf,🇬🇫
|
||||
Guam,Guam,GU,GUM,316,Oceania,Micronesia,Hagåtña,153836,549,USD,cha | eng | spa,.gu,🇬🇺
|
||||
Guyana,Co-operative Republic of Guyana,GY,GUY,328,Americas,South America,Georgetown,772975,214969,GYD,eng,.gy,🇬🇾
|
||||
Hong Kong,Hong Kong Special Administrative Region of the People's Republic of China,HK,HKG,344,Asia,Eastern Asia,City of Victoria,7527500,1104,HKD,eng | zho,.hk | .香港,🇭🇰
|
||||
Heard Island and McDonald Islands,Heard Island and McDonald Islands,HM,HMD,334,Antarctic,,,0,412,,eng,.hm | .aq,🇭🇲
|
||||
Honduras,Republic of Honduras,HN,HND,340,Americas,Central America,Tegucigalpa,9892632,112492,HNL,spa,.hn,🇭🇳
|
||||
Croatia,Republic of Croatia,HR,HRV,191,Europe,Southeast Europe,Zagreb,3866233,56594,EUR,hrv,.hr,🇭🇷
|
||||
Haiti,Republic of Haiti,HT,HTI,332,Americas,Caribbean,Port-au-Prince,11867032,27750,HTG,fra | hat,.ht,🇭🇹
|
||||
Hungary,Hungary,HU,HUN,348,Europe,Central Europe,Budapest,9539502,93028,HUF,hun,.hu,🇭🇺
|
||||
Indonesia,Republic of Indonesia,ID,IDN,360,Asia,South-Eastern Asia,Jakarta,284438782,1904569,IDR,ind,.id,🇮🇩
|
||||
Isle of Man,Isle of Man,IM,IMN,833,Europe,Northern Europe,Douglas,84530,572,GBP | IMP,eng | glv,.im,🇮🇲
|
||||
India,Republic of India,IN,IND,356,Asia,Southern Asia,New Delhi,1417492000,3287263,INR,eng | hin | tam,.in,🇮🇳
|
||||
British Indian Ocean Territory,British Indian Ocean Territory,IO,IOT,086,Africa,Eastern Africa,Diego Garcia,0,60,USD,eng,.io,🇮🇴
|
||||
Ireland,Republic of Ireland,IE,IRL,372,Europe,Northern Europe,Dublin,5458600,70273,EUR,eng | gle,.ie,🇮🇪
|
||||
Iran,Islamic Republic of Iran,IR,IRN,364,Asia,Southern Asia,Tehran,85961000,1648195,IRR,fas,.ir | ایران.,🇮🇷
|
||||
Iraq,Republic of Iraq,IQ,IRQ,368,Asia,Western Asia,Baghdad,46118793,438317,IQD,ara | arc | ckb,.iq,🇮🇶
|
||||
Iceland,Iceland,IS,ISL,352,Europe,Northern Europe,Reykjavik,391810,103000,ISK,isl,.is,🇮🇸
|
||||
Israel,State of Israel,IL,ISR,376,Asia,Western Asia,Jerusalem,10134800,21937,ILS,ara | heb,.il,🇮🇱
|
||||
Italy,Italian Republic,IT,ITA,380,Europe,Southern Europe,Rome,58927633,301336,EUR,cat | ita,.it,🇮🇹
|
||||
Jamaica,Jamaica,JM,JAM,388,Americas,Caribbean,Kingston,2825544,10991,JMD,eng | jam,.jm,🇯🇲
|
||||
Jersey,Bailiwick of Jersey,JE,JEY,832,Europe,Northern Europe,Saint Helier,103267,116,GBP | JEP,eng | fra | nrf,.je,🇯🇪
|
||||
Jordan,Hashemite Kingdom of Jordan,JO,JOR,400,Asia,Western Asia,Amman,11734000,89342,JOD,ara,.jo | الاردن.,🇯🇴
|
||||
Japan,Japan,JP,JPN,392,Asia,Eastern Asia,Tokyo,123210000,377930,JPY,jpn,.jp | .みんな,🇯🇵
|
||||
Kazakhstan,Republic of Kazakhstan,KZ,KAZ,398,Asia,Central Asia,Astana,20426568,2724900,KZT,kaz | rus,.kz | .қаз,🇰🇿
|
||||
Kenya,Republic of Kenya,KE,KEN,404,Africa,Eastern Africa,Nairobi,53330978,580367,KES,eng | swa,.ke,🇰🇪
|
||||
Kyrgyzstan,Kyrgyz Republic,KG,KGZ,417,Asia,Central Asia,Bishkek,7281800,199951,KGS,kir | rus,.kg,🇰🇬
|
||||
Cambodia,Kingdom of Cambodia,KH,KHM,116,Asia,South-Eastern Asia,Phnom Penh,17577760,181035,KHR | USD,khm,.kh,🇰🇭
|
||||
Kiribati,Independent and Sovereign Republic of Kiribati,KI,KIR,296,Oceania,Micronesia,South Tarawa,120740,811,AUD | KID,eng | gil,.ki,🇰🇮
|
||||
Saint Kitts and Nevis,Federation of Saint Christopher and Nevis,KN,KNA,659,Americas,Caribbean,Basseterre,51320,261,XCD,eng,.kn,🇰🇳
|
||||
South Korea,Republic of Korea,KR,KOR,410,Asia,Eastern Asia,Seoul,51159889,100210,KRW,kor,.kr | .한국,🇰🇷
|
||||
Kosovo,Republic of Kosovo,XK,UNK,,Europe,Southeast Europe,Pristina,1585566,10908,EUR,sqi | srp,,🇽🇰
|
||||
Kuwait,State of Kuwait,KW,KWT,414,Asia,Western Asia,Kuwait City,4881254,17818,KWD,ara,.kw,🇰🇼
|
||||
Laos,Lao People's Democratic Republic,LA,LAO,418,Asia,South-Eastern Asia,Vientiane,7647000,236800,LAK,lao,.la,🇱🇦
|
||||
Lebanon,Lebanese Republic,LB,LBN,422,Asia,Western Asia,Beirut,5490000,10452,LBP,ara | fra,.lb,🇱🇧
|
||||
Liberia,Republic of Liberia,LR,LBR,430,Africa,Western Africa,Monrovia,5248621,111369,LRD,eng,.lr,🇱🇷
|
||||
Libya,State of Libya,LY,LBY,434,Africa,Northern Africa,Tripoli,7459000,1759540,LYD,ara,.ly,🇱🇾
|
||||
Saint Lucia,Saint Lucia,LC,LCA,662,Americas,Caribbean,Castries,184100,616,XCD,eng,.lc,🇱🇨
|
||||
Liechtenstein,Principality of Liechtenstein,LI,LIE,438,Europe,Western Europe,Vaduz,40900,160,CHF,deu,.li,🇱🇮
|
||||
Sri Lanka,Democratic Socialist Republic of Sri Lanka,LK,LKA,144,Asia,Southern Asia,Sri Jayawardenepura Kotte,21763170,65610,LKR,sin | tam,.lk | .இலங்கை | .ලංකා,🇱🇰
|
||||
Lesotho,Kingdom of Lesotho,LS,LSO,426,Africa,Southern Africa,Maseru,2116427,30355,LSL | ZAR,eng | sot,.ls,🇱🇸
|
||||
Lithuania,Republic of Lithuania,LT,LTU,440,Europe,Northern Europe,Vilnius,2894886,65300,EUR,lit,.lt,🇱🇹
|
||||
Luxembourg,Grand Duchy of Luxembourg,LU,LUX,442,Europe,Western Europe,Luxembourg,681973,2586,EUR,deu | fra | ltz,.lu,🇱🇺
|
||||
Latvia,Republic of Latvia,LV,LVA,428,Europe,Northern Europe,Riga,1829000,64559,EUR,lav,.lv,🇱🇻
|
||||
Macau,Macao Special Administrative Region of the People's Republic of China,MO,MAC,446,Asia,Eastern Asia,,685900,30,MOP,por | zho,.mo,🇲🇴
|
||||
Saint Martin,Saint Martin,MF,MAF,663,Americas,Caribbean,Marigot,31496,53,EUR,fra,.fr | .gp,🇲🇫
|
||||
Morocco,Kingdom of Morocco,MA,MAR,504,Africa,Northern Africa,Rabat,36828330,446550,MAD,ara | ber,.ma | المغرب.,🇲🇦
|
||||
Monaco,Principality of Monaco,MC,MCO,492,Europe,Western Europe,Monaco,38423,2.02,EUR,fra,.mc,🇲🇨
|
||||
Moldova,Republic of Moldova,MD,MDA,498,Europe,Eastern Europe,Chișinău,2749076,33847,MDL,ron,.md,🇲🇩
|
||||
Madagascar,Republic of Madagascar,MG,MDG,450,Africa,Eastern Africa,Antananarivo,31727042,587041,MGA,fra | mlg,.mg,🇲🇬
|
||||
Maldives,Republic of the Maldives,MV,MDV,462,Asia,Southern Asia,Malé,515132,300,MVR,div,.mv,🇲🇻
|
||||
Mexico,United Mexican States,MX,MEX,484,Americas,North America,Mexico City,130575786,1964375,MXN,spa,.mx,🇲🇽
|
||||
Marshall Islands,Republic of the Marshall Islands,MH,MHL,584,Oceania,Micronesia,Majuro,42418,181,USD,eng | mah,.mh,🇲🇭
|
||||
North Macedonia,Republic of North Macedonia,MK,MKD,807,Europe,Southeast Europe,Skopje,1822612,25713,MKD,mkd,.mk,🇲🇰
|
||||
Mali,Republic of Mali,ML,MLI,466,Africa,Western Africa,Bamako,22395489,1240192,XOF,fra,.ml,🇲🇱
|
||||
Malta,Republic of Malta,MT,MLT,470,Europe,Southern Europe,Valletta,574250,316,EUR,eng | mlt,.mt,🇲🇹
|
||||
Myanmar,Republic of the Union of Myanmar,MM,MMR,104,Asia,South-Eastern Asia,Naypyidaw,51316756,676578,MMK,mya,.mm,🇲🇲
|
||||
Montenegro,Montenegro,ME,MNE,499,Europe,Southeast Europe,Podgorica,623327,13812,EUR,cnr,.me,🇲🇪
|
||||
Mongolia,Mongolia,MN,MNG,496,Asia,Eastern Asia,Ulan Bator,3544835,1564110,MNT,mon,.mn,🇲🇳
|
||||
Northern Mariana Islands,Commonwealth of the Northern Mariana Islands,MP,MNP,580,Oceania,Micronesia,Saipan,47329,464,USD,cal | cha | eng,.mp,🇲🇵
|
||||
Mozambique,Republic of Mozambique,MZ,MOZ,508,Africa,Eastern Africa,Maputo,34090466,801590,MZN,por,.mz,🇲🇿
|
||||
Mauritania,Islamic Republic of Mauritania,MR,MRT,478,Africa,Western Africa,Nouakchott,4927532,1030700,MRU,ara,.mr,🇲🇷
|
||||
Montserrat,Montserrat,MS,MSR,500,Americas,Caribbean,Plymouth,4386,102,XCD,eng,.ms,🇲🇸
|
||||
Martinique,Martinique,MQ,MTQ,474,Americas,Caribbean,Fort-de-France,349925,1128,EUR,fra,.mq,🇲🇶
|
||||
Mauritius,Republic of Mauritius,MU,MUS,480,Africa,Eastern Africa,Port Louis,1243741,2040,MUR,eng | fra | mfe,.mu,🇲🇺
|
||||
Malawi,Republic of Malawi,MW,MWI,454,Africa,Eastern Africa,Lilongwe,20734262,118484,MWK,eng | nya,.mw,🇲🇼
|
||||
Malaysia,Malaysia,MY,MYS,458,Asia,South-Eastern Asia,Kuala Lumpur,34231700,330803,MYR,eng | msa,.my,🇲🇾
|
||||
Mayotte,Department of Mayotte,YT,MYT,175,Africa,Eastern Africa,Mamoudzou,320901,374,EUR,fra,.yt,🇾🇹
|
||||
Namibia,Republic of Namibia,NA,NAM,516,Africa,Southern Africa,Windhoek,3022401,825615,NAD | ZAR,afr | deu | eng | her | hgm | kwn | loz | ndo | tsn,.na,🇳🇦
|
||||
New Caledonia,New Caledonia,NC,NCL,540,Oceania,Melanesia,Nouméa,264596,18575,XPF,fra,.nc,🇳🇨
|
||||
Niger,Republic of Niger,NE,NER,562,Africa,Western Africa,Niamey,26312034,1267000,XOF,fra,.ne,🇳🇪
|
||||
Norfolk Island,Territory of Norfolk Island,NF,NFK,574,Oceania,Australia and New Zealand,Kingston,2188,36,AUD,eng | pih,.nf,🇳🇫
|
||||
Nigeria,Federal Republic of Nigeria,NG,NGA,566,Africa,Western Africa,Abuja,223800000,923768,NGN,eng,.ng,🇳🇬
|
||||
Nicaragua,Republic of Nicaragua,NI,NIC,558,Americas,Central America,Managua,6803886,130373,NIO,spa,.ni,🇳🇮
|
||||
Niue,Niue,NU,NIU,570,Oceania,Polynesia,Alofi,1681,260,NZD,eng | niu,.nu,🇳🇺
|
||||
Netherlands,Kingdom of the Netherlands,NL,NLD,528,Europe,Western Europe,Amsterdam,18100436,41865,EUR,nld,.nl,🇳🇱
|
||||
Norway,Kingdom of Norway,NO,NOR,578,Europe,Northern Europe,Oslo,5606944,386224,NOK,nno | nob | smi,.no,🇳🇴
|
||||
Nepal,Federal Democratic Republic of Nepal,NP,NPL,524,Asia,Southern Asia,Kathmandu,29911840,147181,NPR,nep,.np,🇳🇵
|
||||
Nauru,Republic of Nauru,NR,NRU,520,Oceania,Micronesia,Yaren,11680,21,AUD,eng | nau,.nr,🇳🇷
|
||||
New Zealand,New Zealand,NZ,NZL,554,Oceania,Australia and New Zealand,Wellington,5324700,268838,NZD,eng | mri | nzs,.nz,🇳🇿
|
||||
Oman,Sultanate of Oman,OM,OMN,512,Asia,Western Asia,Muscat,5343630,309500,OMR,ara,.om,🇴🇲
|
||||
Pakistan,Islamic Republic of Pakistan,PK,PAK,586,Asia,Southern Asia,Islamabad,241499431,796095,PKR,eng | urd,.pk,🇵🇰
|
||||
Panama,Republic of Panama,PA,PAN,591,Americas,Central America,Panama City,4064780,75417,PAB | USD,spa,.pa,🇵🇦
|
||||
Pitcairn Islands,Pitcairn Group of Islands,PN,PCN,612,Oceania,Polynesia,Adamstown,35,47,NZD,eng,.pn,🇵🇳
|
||||
Peru,Republic of Peru,PE,PER,604,Americas,South America,Lima,34350244,1285216,PEN,aym | que | spa,.pe,🇵🇪
|
||||
Philippines,Republic of the Philippines,PH,PHL,608,Asia,South-Eastern Asia,Manila,114123600,342353,PHP,eng | fil,.ph,🇵🇭
|
||||
Palau,Republic of Palau,PW,PLW,585,Oceania,Micronesia,Ngerulmud,16733,459,USD,eng | pau,.pw,🇵🇼
|
||||
Papua New Guinea,Independent State of Papua New Guinea,PG,PNG,598,Oceania,Melanesia,Port Moresby,11781559,462840,PGK,eng | hmo | tpi,.pg,🇵🇬
|
||||
Poland,Republic of Poland,PL,POL,616,Europe,Central Europe,Warsaw,37392000,312679,PLN,pol,.pl,🇵🇱
|
||||
Puerto Rico,Commonwealth of Puerto Rico,PR,PRI,630,Americas,Caribbean,San Juan,3203295,8870,USD,eng | spa,.pr,🇵🇷
|
||||
North Korea,Democratic People's Republic of Korea,KP,PRK,408,Asia,Eastern Asia,Pyongyang,25950000,120538,KPW,kor,.kp,🇰🇵
|
||||
Portugal,Portuguese Republic,PT,PRT,620,Europe,Southern Europe,Lisbon,10749635,92090,EUR,por,.pt,🇵🇹
|
||||
Paraguay,Republic of Paraguay,PY,PRY,600,Americas,South America,Asunción,6109644,406752,PYG,grn | spa,.py,🇵🇾
|
||||
Palestine,State of Palestine,PS,PSE,275,Asia,Western Asia,Ramallah | Jerusalem,5483450,6220,EGP | ILS | JOD,ara,.ps | فلسطين.,🇵🇸
|
||||
French Polynesia,French Polynesia,PF,PYF,258,Oceania,Polynesia,Papeetē,279500,4167,XPF,fra,.pf,🇵🇫
|
||||
Qatar,State of Qatar,QA,QAT,634,Asia,Western Asia,Doha,3173024,11586,QAR,ara,.qa | قطر.,🇶🇦
|
||||
Réunion,Réunion Island,RE,REU,638,Africa,Eastern Africa,Saint-Denis,896175,2511,EUR,fra,.re,🇷🇪
|
||||
Romania,Romania,RO,ROU,642,Europe,Southeast Europe,Bucharest,19036031,238391,RON,ron,.ro,🇷🇴
|
||||
Russia,Russian Federation,RU,RUS,643,Europe,Eastern Europe,Moscow,146028325,17098246,RUB,rus,.ru | .su | .рф,🇷🇺
|
||||
Rwanda,Republic of Rwanda,RW,RWA,646,Africa,Eastern Africa,Kigali,14104969,26338,RWF,eng | fra | kin,.rw,🇷🇼
|
||||
Saudi Arabia,Kingdom of Saudi Arabia,SA,SAU,682,Asia,Western Asia,Riyadh,35300280,2149690,SAR,ara,.sa | .السعودية,🇸🇦
|
||||
Sudan,Republic of the Sudan,SD,SDN,729,Africa,Northern Africa,Khartoum,51662000,1886068,SDG,ara | eng,.sd,🇸🇩
|
||||
Senegal,Republic of Senegal,SN,SEN,686,Africa,Western Africa,Dakar,18593258,196722,XOF,fra,.sn,🇸🇳
|
||||
Singapore,Republic of Singapore,SG,SGP,702,Asia,South-Eastern Asia,Singapore,6110200,710,SGD,eng | msa | tam | zho,.sg | .新加坡 | .சிங்கப்பூர்,🇸🇬
|
||||
South Georgia,South Georgia and the South Sandwich Islands,GS,SGS,239,Antarctic,,King Edward Point,0,3903,GBP,eng,.gs,🇬🇸
|
||||
Svalbard and Jan Mayen,Svalbard og Jan Mayen,SJ,SJM,744,Europe,Northern Europe,Longyearbyen,2530,61399,NOK,nor,.sj,🇸🇯
|
||||
Solomon Islands,Solomon Islands,SB,SLB,090,Oceania,Melanesia,Honiara,750325,28896,SBD,eng,.sb,🇸🇧
|
||||
Sierra Leone,Republic of Sierra Leone,SL,SLE,694,Africa,Western Africa,Freetown,9077691,71740,SLE,eng,.sl,🇸🇱
|
||||
El Salvador,Republic of El Salvador,SV,SLV,222,Americas,Central America,San Salvador,6029976,21041,USD,spa,.sv,🇸🇻
|
||||
San Marino,Republic of San Marino,SM,SMR,674,Europe,Southern Europe,City of San Marino,34132,61,EUR,ita,.sm,🇸🇲
|
||||
Somalia,Federal Republic of Somalia,SO,SOM,706,Africa,Eastern Africa,Mogadishu,19655000,637657,SOS,ara | som,.so,🇸🇴
|
||||
Saint Pierre and Miquelon,Saint Pierre and Miquelon,PM,SPM,666,Americas,North America,Saint-Pierre,5819,242,EUR,fra,.pm,🇵🇲
|
||||
Serbia,Republic of Serbia,RS,SRB,688,Europe,Southeast Europe,Belgrade,6567783,77589,RSD,srp,.rs | .срб,🇷🇸
|
||||
South Sudan,Republic of South Sudan,SS,SSD,728,Africa,Middle Africa,Juba,15786898,619745,SSP,eng,.ss,🇸🇸
|
||||
São Tomé and Príncipe,Democratic Republic of São Tomé and Príncipe,ST,STP,678,Africa,Middle Africa,São Tomé,209607,964,STN,por,.st,🇸🇹
|
||||
Suriname,Republic of Suriname,SR,SUR,740,Americas,South America,Paramaribo,616500,163820,SRD,nld,.sr,🇸🇷
|
||||
Slovakia,Slovak Republic,SK,SVK,703,Europe,Central Europe,Bratislava,5413813,49037,EUR,slk,.sk,🇸🇰
|
||||
Slovenia,Republic of Slovenia,SI,SVN,705,Europe,Central Europe,Ljubljana,2130638,20273,EUR,slv,.si,🇸🇮
|
||||
Sweden,Kingdom of Sweden,SE,SWE,752,Europe,Northern Europe,Stockholm,10605098,450295,SEK,swe,.se,🇸🇪
|
||||
Eswatini,Kingdom of Eswatini,SZ,SWZ,748,Africa,Southern Africa,Mbabane,1235549,17364,SZL | ZAR,eng | ssw,.sz,🇸🇿
|
||||
Sint Maarten,Sint Maarten,SX,SXM,534,Americas,Caribbean,Philipsburg,41349,34,ANG,eng | fra | nld,.sx,🇸🇽
|
||||
Seychelles,Republic of Seychelles,SC,SYC,690,Africa,Eastern Africa,Victoria,122729,452,SCR,crs | eng | fra,.sc,🇸🇨
|
||||
Syria,Syrian Arab Republic,SY,SYR,760,Asia,Western Asia,Damascus,25620000,185180,SYP,ara,.sy | سوريا.,🇸🇾
|
||||
Turks and Caicos Islands,Turks and Caicos Islands,TC,TCA,796,Americas,Caribbean,Cockburn Town,50828,948,USD,eng,.tc,🇹🇨
|
||||
Chad,Republic of Chad,TD,TCD,148,Africa,Middle Africa,N'Djamena,19340757,1284000,XAF,ara | fra,.td,🇹🇩
|
||||
Togo,Togolese Republic,TG,TGO,768,Africa,Western Africa,Lomé,8095498,56785,XOF,fra,.tg,🇹🇬
|
||||
Thailand,Kingdom of Thailand,TH,THA,764,Asia,South-Eastern Asia,Bangkok,65859640,513120,THB,tha,.th | .ไทย,🇹🇭
|
||||
Tajikistan,Republic of Tajikistan,TJ,TJK,762,Asia,Central Asia,Dushanbe,10499000,143100,TJS,rus | tgk,.tj,🇹🇯
|
||||
Tokelau,Tokelau,TK,TKL,772,Oceania,Polynesia,Fakaofo,2608,12,NZD,eng | smo | tkl,.tk,🇹🇰
|
||||
Turkmenistan,Turkmenistan,TM,TKM,795,Asia,Central Asia,Ashgabat,7057841,488100,TMT,rus | tuk,.tm,🇹🇲
|
||||
Timor-Leste,Democratic Republic of Timor-Leste,TL,TLS,626,Asia,South-Eastern Asia,Dili,1391221,14874,USD,por | tet,.tl,🇹🇱
|
||||
Tonga,Kingdom of Tonga,TO,TON,776,Oceania,Polynesia,Nuku'alofa,100179,747,TOP,eng | ton,.to,🇹🇴
|
||||
Trinidad and Tobago,Republic of Trinidad and Tobago,TT,TTO,780,Americas,Caribbean,Port of Spain,1367764,5130,TTD,eng,.tt,🇹🇹
|
||||
Tunisia,Tunisian Republic,TN,TUN,788,Africa,Northern Africa,Tunis,11972169,163610,TND,ara,.tn,🇹🇳
|
||||
Turkey,Republic of Turkey,TR,TUR,792,Asia,Western Asia,Ankara,85664944,783562,TRY,tur,.tr,🇹🇷
|
||||
Tuvalu,Tuvalu,TV,TUV,798,Oceania,Polynesia,Funafuti,10643,26,AUD | TVD,eng | tvl,.tv,🇹🇻
|
||||
Taiwan,Republic of China (Taiwan),TW,TWN,158,Asia,Eastern Asia,Taipei,23317031,36197,TWD,zho,.tw | .台灣 | .台湾,🇹🇼
|
||||
Tanzania,United Republic of Tanzania,TZ,TZA,834,Africa,Eastern Africa,Dodoma,68153004,947303,TZS,eng | swa,.tz,🇹🇿
|
||||
Uganda,Republic of Uganda,UG,UGA,800,Africa,Eastern Africa,Kampala,45905417,241550,UGX,eng | swa,.ug,🇺🇬
|
||||
Ukraine,Ukraine,UA,UKR,804,Europe,Eastern Europe,Kyiv,32862000,603550,UAH,ukr,.ua | .укр,🇺🇦
|
||||
United States Minor Outlying Islands,United States Minor Outlying Islands,UM,UMI,581,Americas,North America,Washington DC,0,34.2,USD,eng,.us,🇺🇲
|
||||
Uruguay,Oriental Republic of Uruguay,UY,URY,858,Americas,South America,Montevideo,3499451,181034,UYU,spa,.uy,🇺🇾
|
||||
United States,United States of America,US,USA,840,Americas,North America,"Washington, D.C.",340110988,9525067,USD,eng,.us,🇺🇸
|
||||
Uzbekistan,Republic of Uzbekistan,UZ,UZB,860,Asia,Central Asia,Tashkent,37859698,447400,UZS,rus | uzb,.uz,🇺🇿
|
||||
Vatican City,Vatican City State,VA,VAT,336,Europe,Southern Europe,Vatican City,882,0.49,EUR,ita | lat,.va,🇻🇦
|
||||
Saint Vincent and the Grenadines,Saint Vincent and the Grenadines,VC,VCT,670,Americas,Caribbean,Kingstown,110872,389,XCD,eng,.vc,🇻🇨
|
||||
Venezuela,Bolivarian Republic of Venezuela,VE,VEN,862,Americas,South America,Caracas,28517000,916445,VES,spa,.ve,🇻🇪
|
||||
British Virgin Islands,Virgin Islands,VG,VGB,092,Americas,Caribbean,Road Town,39471,151,USD,eng,.vg,🇻🇬
|
||||
United States Virgin Islands,Virgin Islands of the United States,VI,VIR,850,Americas,Caribbean,Charlotte Amalie,87146,347,USD,eng,.vi,🇻🇮
|
||||
Vietnam,Socialist Republic of Vietnam,VN,VNM,704,Asia,South-Eastern Asia,Hanoi,101343800,331212,VND,vie,.vn,🇻🇳
|
||||
Vanuatu,Republic of Vanuatu,VU,VUT,548,Oceania,Melanesia,Port Vila,321409,12189,VUV,bis | eng | fra,.vu,🇻🇺
|
||||
Wallis and Futuna,Territory of the Wallis and Futuna Islands,WF,WLF,876,Oceania,Polynesia,Mata-Utu,11620,142,XPF,fra,.wf,🇼🇫
|
||||
Samoa,Independent State of Samoa,WS,WSM,882,Oceania,Polynesia,Apia,205557,2842,WST,eng | smo,.ws,🇼🇸
|
||||
Yemen,Republic of Yemen,YE,YEM,887,Asia,Western Asia,Sana'a,32684503,527968,YER,ara,.ye,🇾🇪
|
||||
South Africa,Republic of South Africa,ZA,ZAF,710,Africa,Southern Africa,Pretoria | Bloemfontein | Cape Town,63100945,1221037,ZAR,afr | eng | nbl | nso | sot | ssw | tsn | tso | ven | xho | zul,.za,🇿🇦
|
||||
Zambia,Republic of Zambia,ZM,ZMB,894,Africa,Eastern Africa,Lusaka,19693423,752612,ZMW,eng,.zm,🇿🇲
|
||||
Zimbabwe,Republic of Zimbabwe,ZW,ZWE,716,Africa,Southern Africa,Harare,17073087,390757,ZWL,bwg | eng | kck | khi | ndc | nde | nya | sna | sot | toi | tsn | tso | ven | xho | zib,.zw,🇿🇼
|
||||
|
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Flatten the REST Countries v3.1 dataset into a clean, flat table.
|
||||
|
||||
Usage:
|
||||
python3 extract_countries.py <source_json> <output_csv>
|
||||
|
||||
Source (raw, from the REST Countries repository):
|
||||
https://raw.githubusercontent.com/restcountries/restcountries/master/src/main/resources/countriesV3.1.json
|
||||
The JSON is an array of 250 country records; this script flattens every record
|
||||
to one CSV row with the fixed 14-column contract below.
|
||||
|
||||
Columns (order):
|
||||
name_common | name_official | alpha2 | alpha3 | numeric |
|
||||
region | subregion | capital | population | area_km2 |
|
||||
currencies | languages | tlds | flag
|
||||
"""
|
||||
import csv
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
def as_text(value):
|
||||
"""Empty string for None/empty, plain str otherwise."""
|
||||
if value is None or value == '':
|
||||
return ''
|
||||
return str(value)
|
||||
|
||||
|
||||
def list_join(value):
|
||||
"""Join a list of strings with ' | '; empty string for None."""
|
||||
if value is None:
|
||||
return ''
|
||||
return ' | '.join(str(item) for item in value)
|
||||
|
||||
|
||||
def currency_codes(currencies):
|
||||
if not isinstance(currencies, dict):
|
||||
return ''
|
||||
return ' | '.join(sorted(currencies.keys()))
|
||||
|
||||
|
||||
def language_codes(languages):
|
||||
if not isinstance(languages, dict):
|
||||
return ''
|
||||
return ' | '.join(sorted(languages.keys()))
|
||||
|
||||
|
||||
def flatten(record):
|
||||
name = record.get('name') or {}
|
||||
return [
|
||||
as_text(name.get('common')), # name_common
|
||||
as_text(name.get('official')), # name_official
|
||||
as_text(record.get('cca2')), # alpha2
|
||||
as_text(record.get('cca3')), # alpha3
|
||||
as_text(record.get('ccn3')), # numeric
|
||||
as_text(record.get('region')), # region
|
||||
as_text(record.get('subregion')), # subregion
|
||||
list_join(record.get('capital')), # capital
|
||||
as_text(record.get('population')), # population
|
||||
as_text(record.get('area')), # area_km2
|
||||
currency_codes(record.get('currencies')), # currencies
|
||||
language_codes(record.get('languages')), # languages
|
||||
list_join(record.get('tld')), # tlds
|
||||
as_text(record.get('flag')), # flag
|
||||
]
|
||||
|
||||
|
||||
HEADERS = [
|
||||
'name_common', 'name_official', 'alpha2', 'alpha3', 'numeric',
|
||||
'region', 'subregion', 'capital', 'population', 'area_km2',
|
||||
'currencies', 'languages', 'tlds', 'flag',
|
||||
]
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 3:
|
||||
sys.stderr.write('usage: extract_countries.py <source_json> <output_csv>\n')
|
||||
return 2
|
||||
source_path, out_path = sys.argv[1], sys.argv[2]
|
||||
try:
|
||||
with open(source_path, encoding='utf-8') as fh:
|
||||
records = json.load(fh)
|
||||
except (OSError, ValueError) as exc:
|
||||
sys.stderr.write('cannot read source %s: %s\n' % (source_path, exc))
|
||||
return 1
|
||||
if not isinstance(records, list):
|
||||
sys.stderr.write('source JSON is not a list\n')
|
||||
return 1
|
||||
with open(out_path, 'w', encoding='utf-8', newline='') as fh:
|
||||
writer = csv.writer(fh, lineterminator='\n')
|
||||
writer.writerow(HEADERS)
|
||||
for record in records:
|
||||
writer.writerow(flatten(record))
|
||||
print('records_in: %d' % len(records))
|
||||
print('wrote: %s' % out_path)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Independent cross-check: extracted CSV vs the raw source JSON.
|
||||
|
||||
Usage:
|
||||
python3 verify_extraction.py <source_json> <csv_path>
|
||||
|
||||
Verifies that every source record appears exactly once in the CSV:
|
||||
- row count equals the source record count
|
||||
- alpha-2 code sets match exactly
|
||||
- name_common values match for every row
|
||||
|
||||
Exits 0 only if all checks pass. Evidence, not the formal gate.
|
||||
"""
|
||||
import csv
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 3:
|
||||
sys.stderr.write('usage: verify_extraction.py <source_json> <csv_path>\n')
|
||||
return 2
|
||||
source_path, csv_path = sys.argv[1], sys.argv[2]
|
||||
try:
|
||||
with open(source_path, encoding='utf-8') as fh:
|
||||
records = json.load(fh)
|
||||
except (OSError, ValueError) as exc:
|
||||
sys.stderr.write('cannot read source %s: %s\n' % (source_path, exc))
|
||||
return 1
|
||||
if not isinstance(records, list):
|
||||
sys.stderr.write('source JSON is not a list\n')
|
||||
return 1
|
||||
|
||||
source = {}
|
||||
for rec in records:
|
||||
code = str(rec.get('cca2')) if rec.get('cca2') else None
|
||||
name = str((rec.get('name') or {}).get('common')) if rec.get('name') else ''
|
||||
if code:
|
||||
source[code] = name
|
||||
|
||||
try:
|
||||
with open(csv_path, encoding='utf-8') as fh:
|
||||
rows = list(csv.reader(fh))
|
||||
except OSError as exc:
|
||||
sys.stderr.write('cannot read csv %s: %s\n' % (csv_path, exc))
|
||||
return 1
|
||||
if not rows:
|
||||
sys.stderr.write('csv is empty\n')
|
||||
return 1
|
||||
header, data = rows[0], rows[1:]
|
||||
problems = []
|
||||
if len(data) != len(source):
|
||||
problems.append('row count %d != source count %d'
|
||||
% (len(data), len(source)))
|
||||
|
||||
csv_codes = {}
|
||||
for row in data:
|
||||
if len(row) != 14:
|
||||
problems.append('row with %d fields: %r' % (len(row), row))
|
||||
continue
|
||||
csv_codes[row[2]] = row[0]
|
||||
|
||||
missing = sorted(set(source) - set(csv_codes))
|
||||
extra = sorted(set(csv_codes) - set(source))
|
||||
if missing:
|
||||
problems.append('alpha-2 missing from csv: %r' % missing)
|
||||
if extra:
|
||||
problems.append('alpha-2 extra in csv: %r' % extra)
|
||||
mismatches = [c for c in source if csv_codes.get(c) != source[c]]
|
||||
if mismatches:
|
||||
problems.append('name_common mismatches: %r' % mismatches)
|
||||
|
||||
if problems:
|
||||
sys.stderr.write('VERIFY FAILED\n')
|
||||
for problem in problems:
|
||||
sys.stderr.write(' - %s\n' % problem)
|
||||
return 1
|
||||
print('verify: ok rows=%d codes=%d source=%d header=%r'
|
||||
% (len(data), len(csv_codes), len(source), header))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
Reference in new issue
Block a user