Python Fake Data - Create a Simple python application to generate Fake data

Published February 07, 2022

As the name implies, fake data refers to phony data or random data that is created primarily for operational and testing reasons. It may be used as a substitute for real data and is used by developers when testing the programs they have created, and the performance of the program is dependent on various sorts of data inputs.

Using the Faker package, we generate fake data. This package enables the creation of several types of fake data. You can use this package to generate random data such as nation, email, city, name, etc.

This package also supports a variety of languages and locales for data generation, depending on location.

Let's have a look at how we may make a simple Python program that creates fake data. We are going to generate fake general profile data, fake male profile data, and fake female data.

 

Step 1: First, install all the required modules.  

Install the Faker package in your application using the command below.

 

$ pip install Faker

 

In addition, install the Dumper to provide a good console for outputting the dumping variables.

 

$ pip install Dumper

 

Step 2: After installing the faker package in the terminal, paste the code below to import all the required modules in this application.
 

from faker import Faker

import dumper

 

Step 3: Now paste the code below to generate the fake general profile data, fake male profile data and fake female data.

from faker import Faker

import dumper

faker = Faker()

profile1 = faker.simple_profile()

dumper.dump(profile1)

print('--------------------------')

profile2 = faker.simple_profile('M')

dumper.dump(profile2)

print('--------------------------')

profile3 = faker.profile(sex='F')

dumper.dump(profile3)

 

Step 4: If you run the above code, fake profile data will be automatically generated.

Output

 

Python fake data generator

 

Conclusion: In this Python example we created simple application to create fake data

 

Download Source code

 

Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

233 Views