DEV Community

Cover image for Dummy data generation with Python
petercour
petercour

Posted on

Dummy data generation with Python

Do you need Dummy data for your app? You can do that with the Python programming language. The module Faker lets you generate fake data.

That is very useful when you are just starting out building an app and do not have any data yet.

#!/usr/bin/python3
from faker import Faker
fake = Faker()

print(fake.name())

It will generate a new name each run:

λ  python3 test.py  
Sean Weber
λ  python3 test.py
Angelica Watson

It can automatically generate an address to:

#!/usr/bin/python3
from faker import Faker
fake = Faker()

print(fake.name())
print(fake.address())

Example run:

Dr. Derek Scott
010 Ortega Spring
Samanthaburgh, CT 36146

These are all English names and addresses. It works for international fake data too:

Just add the locale, for Italy:

fake = Faker('it_IT')

If you need many fake names and addresses, use a for loop to wrap it in.

Related links:

Top comments (0)