Skip to content

Instantly share code, notes, and snippets.

@mudongliang
Last active February 29, 2024 05:25
Show Gist options
  • Save mudongliang/e0de9053115e705017b38695389ecf69 to your computer and use it in GitHub Desktop.
Save mudongliang/e0de9053115e705017b38695389ecf69 to your computer and use it in GitHub Desktop.
import pycountry
import json
def check_iso_standard(src):
for college in src:
#print(college["alpha_two_code"])
#print(college["country"])
alpha2 = college["alpha_two_code"]
name = college["country"]
result = pycountry.countries.get(alpha_2=alpha2)
if result is None:
print(alpha2, "is not found in iso3166-1")
else:
if result.name != name and result.common_name != name:
print(result.name, "and", name, "does not match")
def main():
with open("./world_universities_and_domains.json", "r") as ro_file:
src = json.load(ro_file)
if src is None:
return
check_iso_standard(src)
if __name__ == "__main__":
main()
@mudongliang
Copy link
Author

mudongliang commented Feb 23, 2024

$ python test.py | sort | uniq > result
  • Brazil and BR does not match
  • Cabo Verde and Cape Verde does not match
  • Congo, The Democratic Republic of the and Congo, the Democratic Republic of the does not match
  • Czechia and Czech Republic does not match
  • Eswatini and Swaziland does not match (Not sure)
  • Iran, Islamic Republic of and Iran does not match (Not sure)
  • Taiwan, Province of China and Taiwan does not match
  • Türkiye and Turkey does not match
  • UK is not found in iso3166-1
  • United States and US does not match
  • Viet Nam and Vietnam does not match
  • XK is not found in iso3166-1 (Not sure)

@mudongliang
Copy link
Author

should check not only name but also common_name in pycountry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment