ledger: ISO 3166-1 country-code extraction (249 rows)
This commit is contained in:
1 parent
85c4f7f05d
commit
70edcd4b53
3 files changed
+388
No files matched your search
@@ -0,0 +1,250 @@
|
||||
country,alpha2,alpha3,numeric,independent
|
||||
Afghanistan,AF,AFG,004,Yes
|
||||
Albania,AL,ALB,008,Yes
|
||||
Algeria,DZ,DZA,012,Yes
|
||||
American Samoa,AS,ASM,016,No
|
||||
Andorra,AD,AND,020,Yes
|
||||
Angola,AO,AGO,024,Yes
|
||||
Anguilla,AI,AIA,660,No
|
||||
Antarctica,AQ,ATA,010,No
|
||||
Antigua and Barbuda,AG,ATG,028,Yes
|
||||
Argentina,AR,ARG,032,Yes
|
||||
Armenia,AM,ARM,051,Yes
|
||||
Aruba,AW,ABW,533,No
|
||||
Australia,AU,AUS,036,Yes
|
||||
Austria,AT,AUT,040,Yes
|
||||
Azerbaijan,AZ,AZE,031,Yes
|
||||
Bahamas,BS,BHS,044,Yes
|
||||
Bahrain,BH,BHR,048,Yes
|
||||
Bangladesh,BD,BGD,050,Yes
|
||||
Barbados,BB,BRB,052,Yes
|
||||
Belarus,BY,BLR,112,Yes
|
||||
Belgium,BE,BEL,056,Yes
|
||||
Belize,BZ,BLZ,084,Yes
|
||||
Benin,BJ,BEN,204,Yes
|
||||
Bermuda,BM,BMU,060,No
|
||||
Bhutan,BT,BTN,064,Yes
|
||||
"Bolivia, Plurinational State of",BO,BOL,068,Yes
|
||||
"Bonaire, Sint Eustatius and Saba",BQ,BES,535,No
|
||||
Bosnia and Herzegovina,BA,BIH,070,Yes
|
||||
Botswana,BW,BWA,072,Yes
|
||||
Bouvet Island,BV,BVT,074,No
|
||||
Brazil,BR,BRA,076,Yes
|
||||
British Indian Ocean Territory,IO,IOT,086,No
|
||||
Brunei Darussalam,BN,BRN,096,Yes
|
||||
Bulgaria,BG,BGR,100,Yes
|
||||
Burkina Faso,BF,BFA,854,Yes
|
||||
Burundi,BI,BDI,108,Yes
|
||||
Cabo Verde,CV,CPV,132,Yes
|
||||
Cambodia,KH,KHM,116,Yes
|
||||
Cameroon,CM,CMR,120,Yes
|
||||
Canada,CA,CAN,124,Yes
|
||||
Cayman Islands,KY,CYM,136,No
|
||||
Central African Republic,CF,CAF,140,Yes
|
||||
Chad,TD,TCD,148,Yes
|
||||
Chile,CL,CHL,152,Yes
|
||||
China,CN,CHN,156,Yes
|
||||
Christmas Island,CX,CXR,162,No
|
||||
Cocos (Keeling) Islands,CC,CCK,166,No
|
||||
Colombia,CO,COL,170,Yes
|
||||
Comoros,KM,COM,174,Yes
|
||||
Congo,CG,COG,178,Yes
|
||||
"Congo, Democratic Republic of the",CD,COD,180,Yes
|
||||
Cook Islands,CK,COK,184,No
|
||||
Costa Rica,CR,CRI,188,Yes
|
||||
Croatia,HR,HRV,191,Yes
|
||||
Cuba,CU,CUB,192,Yes
|
||||
Curaçao,CW,CUW,531,No
|
||||
Cyprus,CY,CYP,196,Yes
|
||||
Czechia,CZ,CZE,203,Yes
|
||||
Côte d'Ivoire,CI,CIV,384,Yes
|
||||
Denmark,DK,DNK,208,Yes
|
||||
Djibouti,DJ,DJI,262,Yes
|
||||
Dominica,DM,DMA,212,Yes
|
||||
Dominican Republic,DO,DOM,214,Yes
|
||||
Ecuador,EC,ECU,218,Yes
|
||||
Egypt,EG,EGY,818,Yes
|
||||
El Salvador,SV,SLV,222,Yes
|
||||
Equatorial Guinea,GQ,GNQ,226,Yes
|
||||
Eritrea,ER,ERI,232,Yes
|
||||
Estonia,EE,EST,233,Yes
|
||||
Eswatini,SZ,SWZ,748,Yes
|
||||
Ethiopia,ET,ETH,231,Yes
|
||||
Falkland Islands (Malvinas),FK,FLK,238,No
|
||||
Faroe Islands,FO,FRO,234,No
|
||||
Fiji,FJ,FJI,242,Yes
|
||||
Finland,FI,FIN,246,Yes
|
||||
France,FR,FRA,250,Yes
|
||||
French Guiana,GF,GUF,254,No
|
||||
French Polynesia,PF,PYF,258,No
|
||||
French Southern Territories,TF,ATF,260,No
|
||||
Gabon,GA,GAB,266,Yes
|
||||
Gambia,GM,GMB,270,Yes
|
||||
Georgia,GE,GEO,268,Yes
|
||||
Germany,DE,DEU,276,Yes
|
||||
Ghana,GH,GHA,288,Yes
|
||||
Gibraltar,GI,GIB,292,No
|
||||
Greece,GR,GRC,300,Yes
|
||||
Greenland,GL,GRL,304,No
|
||||
Grenada,GD,GRD,308,Yes
|
||||
Guadeloupe,GP,GLP,312,No
|
||||
Guam,GU,GUM,316,No
|
||||
Guatemala,GT,GTM,320,Yes
|
||||
Guernsey,GG,GGY,831,No
|
||||
Guinea,GN,GIN,324,Yes
|
||||
Guinea-Bissau,GW,GNB,624,Yes
|
||||
Guyana,GY,GUY,328,Yes
|
||||
Haiti,HT,HTI,332,Yes
|
||||
Heard Island and McDonald Islands,HM,HMD,334,No
|
||||
Holy See,VA,VAT,336,Yes
|
||||
Honduras,HN,HND,340,Yes
|
||||
Hong Kong,HK,HKG,344,No
|
||||
Hungary,HU,HUN,348,Yes
|
||||
Iceland,IS,ISL,352,Yes
|
||||
India,IN,IND,356,Yes
|
||||
Indonesia,ID,IDN,360,Yes
|
||||
"Iran, Islamic Republic of",IR,IRN,364,Yes
|
||||
Iraq,IQ,IRQ,368,Yes
|
||||
Ireland,IE,IRL,372,Yes
|
||||
Isle of Man,IM,IMN,833,No
|
||||
Israel,IL,ISR,376,Yes
|
||||
Italy,IT,ITA,380,Yes
|
||||
Jamaica,JM,JAM,388,Yes
|
||||
Japan,JP,JPN,392,Yes
|
||||
Jersey,JE,JEY,832,No
|
||||
Jordan,JO,JOR,400,Yes
|
||||
Kazakhstan,KZ,KAZ,398,Yes
|
||||
Kenya,KE,KEN,404,Yes
|
||||
Kiribati,KI,KIR,296,Yes
|
||||
"Korea, Democratic People's Republic of",KP,PRK,408,Yes
|
||||
"Korea, Republic of",KR,KOR,410,Yes
|
||||
Kuwait,KW,KWT,414,Yes
|
||||
Kyrgyzstan,KG,KGZ,417,Yes
|
||||
Lao People's Democratic Republic,LA,LAO,418,Yes
|
||||
Latvia,LV,LVA,428,Yes
|
||||
Lebanon,LB,LBN,422,Yes
|
||||
Lesotho,LS,LSO,426,Yes
|
||||
Liberia,LR,LBR,430,Yes
|
||||
Libya,LY,LBY,434,Yes
|
||||
Liechtenstein,LI,LIE,438,Yes
|
||||
Lithuania,LT,LTU,440,Yes
|
||||
Luxembourg,LU,LUX,442,Yes
|
||||
Macao,MO,MAC,446,No
|
||||
Madagascar,MG,MDG,450,Yes
|
||||
Malawi,MW,MWI,454,Yes
|
||||
Malaysia,MY,MYS,458,Yes
|
||||
Maldives,MV,MDV,462,Yes
|
||||
Mali,ML,MLI,466,Yes
|
||||
Malta,MT,MLT,470,Yes
|
||||
Marshall Islands,MH,MHL,584,Yes
|
||||
Martinique,MQ,MTQ,474,No
|
||||
Mauritania,MR,MRT,478,Yes
|
||||
Mauritius,MU,MUS,480,Yes
|
||||
Mayotte,YT,MYT,175,No
|
||||
Mexico,MX,MEX,484,Yes
|
||||
"Micronesia, Federated States of",FM,FSM,583,Yes
|
||||
"Moldova, Republic of",MD,MDA,498,Yes
|
||||
Monaco,MC,MCO,492,Yes
|
||||
Mongolia,MN,MNG,496,Yes
|
||||
Montenegro,ME,MNE,499,Yes
|
||||
Montserrat,MS,MSR,500,No
|
||||
Morocco,MA,MAR,504,Yes
|
||||
Mozambique,MZ,MOZ,508,Yes
|
||||
Myanmar,MM,MMR,104,Yes
|
||||
Namibia,NA,NAM,516,Yes
|
||||
Naoero,NR,NRU,520,Yes
|
||||
Nepal,NP,NPL,524,Yes
|
||||
"Netherlands, Kingdom of the",NL,NLD,528,Yes
|
||||
New Caledonia,NC,NCL,540,No
|
||||
New Zealand,NZ,NZL,554,Yes
|
||||
Nicaragua,NI,NIC,558,Yes
|
||||
Niger,NE,NER,562,Yes
|
||||
Nigeria,NG,NGA,566,Yes
|
||||
Niue,NU,NIU,570,No
|
||||
Norfolk Island,NF,NFK,574,No
|
||||
North Macedonia,MK,MKD,807,Yes
|
||||
Northern Mariana Islands,MP,MNP,580,No
|
||||
Norway,NO,NOR,578,Yes
|
||||
Oman,OM,OMN,512,Yes
|
||||
Pakistan,PK,PAK,586,Yes
|
||||
Palau,PW,PLW,585,Yes
|
||||
"Palestine, State of",PS,PSE,275,No
|
||||
Panama,PA,PAN,591,Yes
|
||||
Papua New Guinea,PG,PNG,598,Yes
|
||||
Paraguay,PY,PRY,600,Yes
|
||||
Peru,PE,PER,604,Yes
|
||||
Philippines,PH,PHL,608,Yes
|
||||
Pitcairn,PN,PCN,612,No
|
||||
Poland,PL,POL,616,Yes
|
||||
Portugal,PT,PRT,620,Yes
|
||||
Puerto Rico,PR,PRI,630,No
|
||||
Qatar,QA,QAT,634,Yes
|
||||
Romania,RO,ROU,642,Yes
|
||||
Russian Federation,RU,RUS,643,Yes
|
||||
Rwanda,RW,RWA,646,Yes
|
||||
Réunion,RE,REU,638,No
|
||||
Saint Barthélemy,BL,BLM,652,No
|
||||
"Saint Helena, Ascension and Tristan da Cunha",SH,SHN,654,No
|
||||
Saint Kitts and Nevis,KN,KNA,659,Yes
|
||||
Saint Lucia,LC,LCA,662,Yes
|
||||
Saint Martin (French part),MF,MAF,663,No
|
||||
Saint Pierre and Miquelon,PM,SPM,666,No
|
||||
Saint Vincent and the Grenadines,VC,VCT,670,Yes
|
||||
Samoa,WS,WSM,882,Yes
|
||||
San Marino,SM,SMR,674,Yes
|
||||
Sao Tome and Principe,ST,STP,678,Yes
|
||||
Saudi Arabia,SA,SAU,682,Yes
|
||||
Senegal,SN,SEN,686,Yes
|
||||
Serbia,RS,SRB,688,Yes
|
||||
Seychelles,SC,SYC,690,Yes
|
||||
Sierra Leone,SL,SLE,694,Yes
|
||||
Singapore,SG,SGP,702,Yes
|
||||
Sint Maarten (Dutch part),SX,SXM,534,No
|
||||
Slovakia,SK,SVK,703,Yes
|
||||
Slovenia,SI,SVN,705,Yes
|
||||
Solomon Islands,SB,SLB,090,Yes
|
||||
Somalia,SO,SOM,706,Yes
|
||||
South Africa,ZA,ZAF,710,Yes
|
||||
South Georgia and the South Sandwich Islands,GS,SGS,239,No
|
||||
South Sudan,SS,SSD,728,Yes
|
||||
Spain,ES,ESP,724,Yes
|
||||
Sri Lanka,LK,LKA,144,Yes
|
||||
Sudan,SD,SDN,729,Yes
|
||||
Suriname,SR,SUR,740,Yes
|
||||
Svalbard and Jan Mayen,SJ,SJM,744,No
|
||||
Sweden,SE,SWE,752,Yes
|
||||
Switzerland,CH,CHE,756,Yes
|
||||
Syrian Arab Republic,SY,SYR,760,Yes
|
||||
"Taiwan, Province of China",TW,TWN,158,No
|
||||
Tajikistan,TJ,TJK,762,Yes
|
||||
"Tanzania, United Republic of",TZ,TZA,834,Yes
|
||||
Thailand,TH,THA,764,Yes
|
||||
Timor-Leste,TL,TLS,626,Yes
|
||||
Togo,TG,TGO,768,Yes
|
||||
Tokelau,TK,TKL,772,No
|
||||
Tonga,TO,TON,776,Yes
|
||||
Trinidad and Tobago,TT,TTO,780,Yes
|
||||
Tunisia,TN,TUN,788,Yes
|
||||
Turkmenistan,TM,TKM,795,Yes
|
||||
Turks and Caicos Islands,TC,TCA,796,No
|
||||
Tuvalu,TV,TUV,798,Yes
|
||||
Türkiye,TR,TUR,792,Yes
|
||||
Uganda,UG,UGA,800,Yes
|
||||
Ukraine,UA,UKR,804,Yes
|
||||
United Arab Emirates,AE,ARE,784,Yes
|
||||
United Kingdom of Great Britain and Northern Ireland,GB,GBR,826,Yes
|
||||
United States Minor Outlying Islands,UM,UMI,581,No
|
||||
United States of America,US,USA,840,Yes
|
||||
Uruguay,UY,URY,858,Yes
|
||||
Uzbekistan,UZ,UZB,860,Yes
|
||||
Vanuatu,VU,VUT,548,Yes
|
||||
"Venezuela, Bolivarian Republic of",VE,VEN,862,Yes
|
||||
Viet Nam,VN,VNM,704,Yes
|
||||
Virgin Islands (British),VG,VGB,092,No
|
||||
Virgin Islands (U.S.),VI,VIR,850,No
|
||||
Wallis and Futuna,WF,WLF,876,No
|
||||
Western Sahara,EH,ESH,732,No
|
||||
Yemen,YE,YEM,887,Yes
|
||||
Zambia,ZM,ZMB,894,Yes
|
||||
Zimbabwe,ZW,ZWE,716,Yes
|
||||
Åland Islands,AX,ALA,248,No
|
||||
|
@@ -0,0 +1,50 @@
|
||||
# ISO 3166-1 extraction — Extract the ISO 3166-1 country-code table from the English Wikipedia (rendered HTML).
|
||||
|
||||
Source: English Wikipedia, ISO 3166-1 article (rendered table)
|
||||
|
||||
Rows: 249
|
||||
|
||||
| country | alpha-2 | alpha-3 | numeric | independent |
|
||||
|---|---|---|---|---|
|
||||
| Afghanistan | AF | AFG | 004 | Yes |
|
||||
| Albania | AL | ALB | 008 | Yes |
|
||||
| Algeria | DZ | DZA | 012 | Yes |
|
||||
| American Samoa | AS | ASM | 016 | No |
|
||||
| Andorra | AD | AND | 020 | Yes |
|
||||
| Angola | AO | AGO | 024 | Yes |
|
||||
| Anguilla | AI | AIA | 660 | No |
|
||||
| Antarctica | AQ | ATA | 010 | No |
|
||||
| Antigua and Barbuda | AG | ATG | 028 | Yes |
|
||||
| Argentina | AR | ARG | 032 | Yes |
|
||||
| Armenia | AM | ARM | 051 | Yes |
|
||||
| Aruba | AW | ABW | 533 | No |
|
||||
| Australia | AU | AUS | 036 | Yes |
|
||||
| Austria | AT | AUT | 040 | Yes |
|
||||
| Azerbaijan | AZ | AZE | 031 | Yes |
|
||||
| Bahamas | BS | BHS | 044 | Yes |
|
||||
| Bahrain | BH | BHR | 048 | Yes |
|
||||
| Bangladesh | BD | BGD | 050 | Yes |
|
||||
| Barbados | BB | BRB | 052 | Yes |
|
||||
| Belarus | BY | BLR | 112 | Yes |
|
||||
| Belgium | BE | BEL | 056 | Yes |
|
||||
| Belize | BZ | BLZ | 084 | Yes |
|
||||
| Benin | BJ | BEN | 204 | Yes |
|
||||
| Bermuda | BM | BMU | 060 | No |
|
||||
| Bhutan | BT | BTN | 064 | Yes |
|
||||
| Bolivia, Plurinational State of | BO | BOL | 068 | Yes |
|
||||
| Bonaire, Sint Eustatius and Saba | BQ | BES | 535 | No |
|
||||
| Bosnia and Herzegovina | BA | BIH | 070 | Yes |
|
||||
| Botswana | BW | BWA | 072 | Yes |
|
||||
| Bouvet Island | BV | BVT | 074 | No |
|
||||
| Brazil | BR | BRA | 076 | Yes |
|
||||
| British Indian Ocean Territory | IO | IOT | 086 | No |
|
||||
| Brunei Darussalam | BN | BRN | 096 | Yes |
|
||||
| Bulgaria | BG | BGR | 100 | Yes |
|
||||
| Burkina Faso | BF | BFA | 854 | Yes |
|
||||
| Burundi | BI | BDI | 108 | Yes |
|
||||
| Cabo Verde | CV | CPV | 132 | Yes |
|
||||
| Cambodia | KH | KHM | 116 | Yes |
|
||||
| Cameroon | CM | CMR | 120 | Yes |
|
||||
| Canada | CA | CAN | 124 | Yes |
|
||||
|
||||
(40 of 249 rows shown; full table in the .csv)
|
||||
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Verify the ISO 3166-1 extraction CSV.
|
||||
|
||||
Usage: python3 verify_ledger_iso3166.py <csv_path>
|
||||
Exit 0 = artifact correct; nonzero = wrong.
|
||||
"""
|
||||
import csv
|
||||
import re
|
||||
import sys
|
||||
|
||||
EXPECTED_HEADER = ["country", "alpha2", "alpha3", "numeric", "independent"]
|
||||
# (country, alpha2, alpha3, numeric) spot checks against the ISO 3166-1 standard.
|
||||
KNOWN = {
|
||||
"Afghanistan": ("AF", "AFG", "004"),
|
||||
"United States": ("US", "USA", "840"),
|
||||
"United Kingdom": ("GB", "GBR", "826"),
|
||||
"China": ("CN", "CHN", "156"),
|
||||
"Åland Islands": ("AX", "ALA", "248"),
|
||||
"South Korea": ("KR", "KOR", "410"),
|
||||
"Czechia": ("CZ", "CZE", "203"),
|
||||
"Iran": ("IR", "IRN", "364"),
|
||||
"Russia": ("RU", "RUS", "643"),
|
||||
"Vietnam": ("VN", "VNM", "704"),
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print("usage: verify_ledger_iso3166.py <csv>")
|
||||
sys.exit(2)
|
||||
path = sys.argv[1]
|
||||
with open(path, newline="", encoding="utf-8") as f:
|
||||
reader = csv.DictReader(f)
|
||||
header = reader.fieldnames
|
||||
rows = list(reader)
|
||||
|
||||
errors = []
|
||||
|
||||
if header != EXPECTED_HEADER:
|
||||
errors.append("header mismatch: %r" % header)
|
||||
|
||||
if len(rows) != 249:
|
||||
errors.append("row count %d != 249" % len(rows))
|
||||
|
||||
seen = set()
|
||||
for i, r in enumerate(rows, start=2):
|
||||
c = r.get("country", "")
|
||||
a2 = r.get("alpha2", "")
|
||||
a3 = r.get("alpha3", "")
|
||||
num = r.get("numeric", "")
|
||||
ind = r.get("independent", "")
|
||||
|
||||
if re.search(r"\[[^\]]*\]", c):
|
||||
errors.append("row %d: footnote marker in country %r" % (i, c))
|
||||
if re.search(r"\[[^\]]*\]", ind):
|
||||
errors.append("row %d: footnote marker in independent %r" % (i, ind))
|
||||
if not c or not a2 or not a3 or not num or not ind:
|
||||
errors.append("row %d: empty field %r" % (i, r))
|
||||
if not re.fullmatch(r"[A-Za-z]{2}", a2):
|
||||
errors.append("row %d: bad alpha2 %r" % (i, a2))
|
||||
if not re.fullmatch(r"[A-Za-z]{3}", a3):
|
||||
errors.append("row %d: bad alpha3 %r" % (i, a3))
|
||||
if not re.fullmatch(r"\d{3}", num):
|
||||
errors.append("row %d: bad numeric %r" % (i, num))
|
||||
if ind not in ("Yes", "No"):
|
||||
errors.append("row %d: bad independent %r" % (i, ind))
|
||||
key = (a2, a3)
|
||||
if key in seen:
|
||||
errors.append("row %d: duplicate alpha3 %s" % (i, a3))
|
||||
seen.add(key)
|
||||
|
||||
if c in KNOWN:
|
||||
exp = KNOWN[c]
|
||||
if (a2, a3, num) != exp:
|
||||
errors.append("row %d: %r got (%s,%s,%s) want %s" % (i, c, a2, a3, num, exp))
|
||||
|
||||
if errors:
|
||||
print("VERIFY FAILED (%d errors)" % len(errors))
|
||||
for e in errors[:20]:
|
||||
print(" -", e)
|
||||
sys.exit(1)
|
||||
|
||||
print("OK: %d rows verified, header=%s" % (len(rows), header))
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user