randname
Python module to generate random name.
Summary
Randname is a python module for generating random name - first and last. It uses official data from appropriate governmental/scientific research centers.
Names are drawn with the consideration of their frequency. Therefor most common name wil be drawn much more often (this feature can be disabled).
Currently supported countries: US, PL, ES.
Default database is small, and constrained to 10000 records for each first and last names for every country. Default data size: 60 000 records
With the full database downloaded from project github page, the amount of names is increased to around 700 000 records.
Installation
Randname is available in python repository, and can be downloaded with pip.
Yes, use rname to install the package.
Usage
Warning
Because randname package on PyPi was already taken, it was named rname
That's why to install in you need to refer to rname:
randname. And you should import is by
referring to randname:
>>> import randname
# Get first name
>>> randname.randfirst()
'John'
# Get last name
>>> randname.randlast()
'Doe'
# Get full name
>>>randname.randfull()
'John Doe'
# Setting directory to external database
>>> randname.database = "/path/to/external/database/"
Database
Default database included in pypi package is very small. To not make the package unnecessary too large, every country have one set of data for last and first names (with distinction for the male, female, neutral name), for the most recent year. Each file contains up to 10000 records.
Currently supported countries:
US:
- 2010, last names (neutral)
- 2018, first names (male, female)
PL:
- 2020, last names (male, female)
- 2021, first names (male, female)
ES:
- 2020, last names (male)
- 2020, first names (male)
Biger database
Full database is bigger and doesn't have the limit of records. If you wan to use it, download it from project github page.
To use other databases specify directory by setting database_path variable
More details about database can be found here
Contribution
If you want to contribute to randname project read contribution for more information.
I am looking especially for help with database creation. More information on how to help/create appropriate data files with names can be found in database guide
Authors & Contributors
Author: Adam Walkiewicz
Contributors: Be first!
License
Randname is licensed under the terms of the MIT license