I have a list of languages and dialects. For these languages I need to get Alpha_3 and country.name (if availavle).
import pycountry
my_langs = ['Aachen German', 'Aalsters', 'Abkhaz', 'Afrikaans', 'Albanian', 'Gheg', 'Altay', 'Old English†']
existing_iso3 = []
for lang in my_langs:
existing_iso3.append(pycountry.languages.get(name=lang))
existing_iso3 = [x for x in existing_iso3 if x is not None]
existing_iso3
Output:
[Language(alpha_2='af', alpha_3='afr', name='Afrikaans', scope='I', type='L'),
Language(alpha_2='sq', alpha_3='sqi', bibliographic='alb', name='Albanian', scope='M', type='L')]
Is there a way to remove this Language before the parenthesis and find country names for these languages?
So the output would be something like a df
Language | Alpha_3 | Country |
---|---|---|
Afrikaans | afr | South Africa |
Albanian | sqi | Albania |
Is it be also possible to look for a match within Languages? For example not for exact match of Aachen German but only German and return Germany