Last active
July 20, 2022 14:22
-
-
Save Ellpeck/570c1c7deef7245f3e9824d906d5b3ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from names_dataset import NameDataset | |
import json | |
nd = NameDataset() | |
firsts = [] | |
lasts = [] | |
countries = ["GB", "US", "FR", "DE", "PT", "ES", "NL", "IT", "MX", "CO", "ZA", "US"] | |
for country in countries: | |
print(country) | |
names = nd.get_top_names(n=1000, country_alpha2=country) | |
firsts.extend(names[country]["M"]) | |
firsts.extend(names[country]["F"]) | |
names = nd.get_top_names(n=2000, country_alpha2=country, use_first_names=False) | |
lasts.extend(names[country]) | |
firsts = list(set(filter(lambda n: not " " in n, firsts))) | |
lasts = list(set(filter(lambda n: not " " in n, lasts))) | |
print(f"Found {len(firsts)} first names") | |
with open("first.json", "w", encoding="utf_8") as f: | |
f.write(json.dumps(firsts, ensure_ascii=False)) | |
print(f"Found {len(lasts)} last names") | |
with open("last.json", "w", encoding="utf_8") as f: | |
f.write(json.dumps(lasts, ensure_ascii=False)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment