Several years ago, I developed a very simple program called barnum to generate fake data that could be used to test applications. Over the years, I had forgotten about it. With the recent closing of Google code, I decided to take the opportunity to move the code to github and see if it might be useful to people.
I am moving the code and re-announcing it for a couple of reasons:
- I will admit that I hated the idea of it totally dying.
- I was curious to see if it is useful to anyone else.
- This would give me the opportunity to get more familiar with git (I am not afraid to admit that mercurial is my favorite but I think I need to expand my knowledge)
- I also chose this as an opportunity to update the code and make it run with python 3.
Barnum will allow you to create the following types of data which can be used to test your own applications :
- First name and/or last name in either gender
- Job title
- Phone number
- Street number and name
- Zip code plus city & state
- Company name
- Credit card number and type (with valid checksum)
- Email addresses
- Sample password
- Words (latin)
- Sentences and/or paragraphs of random latin words
Here is the basic usage and some of the unique aspects of barnum.
from barnum import gen_data
Create some fake names
You can also specify the gender
We can also create job titles based on US Census data
'Security Coordinator Computer'
One of barnum’s unique capabilities is that there is some intelligence to the data creation. We can pass in a US Zip code and barnum will use a valid area code in the fake data.
We can use zip codes for address data.
('12136', 'Old Chatham', 'NY')
('55112', 'Saint Paul', 'MN')
Barnum can create fake sentences and paragraphs as well as nouns for all your data population needs.
'Aliquip vulputate consequat suscipit amet adipiscing molestie dignissim nulla molestie hendrerit.'
'Illum eros et eu ad ipsum vulputate. Delenit commodoconsequat delenitaugue molestie iustoodio nonummy ut erat duis feugait. Doloremagna Utwisi aliquip molestie erat suscipit. Nonummy exerci eufeugiat illum vel nislut nisl at dolor at. nn'
'rifle giraffe nerve kettle'
There is some date creation capability as well.
datetime.datetime(2025, 1, 12, 19, 36, 25, 639016)
datetime.datetime(2014, 2, 23, 19, 37, 29, 323165)
datetime.datetime(2016, 11, 17, 19, 37, 52, 674284)
datetime.date(2007, 3, 25)
Create email and company name info.
'Application Telecom Inc'
'Marion, Navarro & Quintero LLP'
'Application Data Direct Limited'
Finally, you can also create credit card numbers and simple passwords.
One final component available to you is that you can customize the data used to
create your “random” results. Within the source-data directory, there are several
text files. If you choose to customize the files, you can update them and use the
file to regenerate the random data file.
I know there are a lot of areas where this code can be improved. I’m hopeful that placing it on github will breathe some new life into it. However, if there’s no real interest in it, I’ll be able to rest easier knowing that it is being hosted somewhere where others can use it.