In this article, you’ll learn what is the purpose of dummy data generation, using python windows GUI builder to add features and functionalities to python, using python libraries to generate Dummy Data for Windows apps; Getting started with Python4Delphi and RAD Studio, and many more.
Table of Contents
What is the purpose of dummy data generation?
As a Developer or Tester, sometimes we need a large volume of data in the database to test the applications. Manually creating this data and inserting it into the database is not an affordable option if we consider the price and effort involved too. This is where you need the tools for automatically generating as much dummy data as you need, to test or populate your apps at the lowest cost.
Load, performance, and stress testing are just impossible without the help of these data generation tools. These tools are easy to use, and in turn, save a lot of time. It not only saves time for creating lengthy scripts but has also made data generation easy. With just a few lines of Python code, you will be able to create a large volume of data.
To get the data using web scraping, instead of dummy data generation, read this article for tutorials and best options:
Delphi adds powerful GUI features and functionalities to Python
In this tutorial, we’ll build Windows Apps with extensive Test Data Generation capabilities by integrating Python’s Test Data Generation libraries with Embarcadero’s Delphi, using Python4Delphi (P4D).
P4D empowers Python users with Delphi’s award-winning VCL functionalities for Windows which enables us to build native Windows apps 5x faster. This integration enables us to create a modern GUI with Windows 10 looks and responsive controls for our Python Test Data Generation applications. Python4Delphi also comes with an extensive range of demos, use cases, and tutorials.
We’re going to cover the following…
How to use Faker, FauxFactory, lipsum, Mimesis, pandas, and radar Python libraries to Generate Dummy Data for Your Windows Apps
All of them would be integrated with Python4Delphi to create Windows Apps with Test Data Generation capabilities.
Prerequisites
Before we begin to work, download and install the latest Python for your platform. Follow the Python4Delphi installation instructions mentioned here. Alternatively, you can check out the easy instructions found in the Getting Started With Python4Delphi video by Jim McKeeth.
Getting started with Python4Delphi and RAD Studio
First, open and run our Python GUI using project Demo1 from Python4Delphi with RAD Studio. Then insert the script into the lower Memo, click the Execute button, and get the result in the upper Memo. You can find the Demo1 source on GitHub. The behind the scene details of how Delphi manages to run your Python code in this amazing Python GUI can be found at this link.
1. How can I use Faker to generate dummy data?
Faker is a Python package that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill in your persistence to stress test it, or anonymize data taken from a production service, Faker is for you.
After installing Python4Delphi properly, you can get Faker using pip or easy install to your command prompt:
[crayon-6741c9f6acad9235412578/]Don’t forget to put the path where your Faker library installed, to the System Environment Variables:
System Environment Variable Examples
[crayon-6741c9f6acadf893860699/]The following is the code example of Faker and Python4Delphi to generate real-world example: Complex data with nine variables and 1000 rows (Run this inside the lower Memo of Python4Delphi Demo01 GUI):
[crayon-6741c9f6acae1087770809/]Here is the Faker output in the Python GUI:
The code above will generate dummy data with various Python data types and 1000 rows of observations in total, and export it to .CSV file with this look:
To plot the data generated using TChart, read this article to learn how:
2. How to use FauxFactory to Generate Dummy Data?
FauxFactory generates random data for your automated tests easily!
There are times when you’re writing tests for your application when you need to pass random, non-specific data to the areas you are testing. For these scenarios, when all you need is a random string, numbers, dates, times, email address, IP, etc, then FauxFactory can help!
First, here is how you can get FauxFactory:
[crayon-6741c9f6acae2141454744/]The following code is the implementation of FauxFactory to generate a random string, numeric, date, datetime, and email:
[crayon-6741c9f6acae3760718771/]Here are the FauxFactory examples in the Python GUI
3. How do I use lipsum to generate dummy data?
lipsum is a Python simple Lorem Ipsum generator library that can be easily used in your Python applications. Note that this library only generates randomized Lorem Ipsum strings (words, sentences, and paragraphs).
By default, lipsum takes its source text from Cicero’s De finibus bonorum et malorum, but you can specify your own source text if you want (which must be greater than 100kB in size).
First, here is how you can get lipsum:
[crayon-6741c9f6acae4435937123/]Below is the code for generating random 100 words using lipsum (Run the following code inside the lower Memo of Python4Delphi Demo01 GUI):
[crayon-6741c9f6acae5187082225/]lipsum Python4Delphi Results
When generating the content, lipsum will automatically attempt to append punctuation to the end of your sentences and capitalize the first letter of new sentences.
4. How to use Mimesis to generate dummy data?
Mimesis is a high-performance fake data generator for Python, which provides data for a variety of purposes in a variety of languages. The fake data could be used to populate a testing database, create fake API endpoints, create JSON and XML files of arbitrary structure, anonymize data taken from production, etc.
These are the key features of Mimesis:
- Performance: The fastest data generator available for Python.
- Extensibility: You can create your own data providers and use them with Mimesis.
- Generic data provider: The simplified access to all the providers from a single object.
- Multilingual: Supports data for a lot of languages.
- Data variety: Supports a lot of data providers for a variety of purposes.
- Schema-based generators: Provides an easy mechanism to generate data by the schema of any complexity.
- Country-specific data providers: Provides data specific only for some countries.
First, here is how you can get Mimesis:
[crayon-6741c9f6acae6106739386/]Run these simple examples of Mimesis code, to introduce you to generate person full name with different gender and nationality, generate email address, and more inside the lower Memo of Python4Delphi Demo01 GUI:
[crayon-6741c9f6acae7506328793/]Mimesis Simple yet Powerful Examples:
5. How to Generate Numeric Dummy Data with pandas?
pandas is a Python package that provides fast, flexible, and expressive data structures designed to make working with “relational” or “labeled” data both easy and intuitive. It aims to be the fundamental high-level building block for doing practical, real-world data analysis in Python. Additionally, it has the broader goal of becoming the most powerful and flexible open-source data analysis/manipulation tool available in any language. It is already well on its way towards this goal.
Here is how you can install pandas:
[crayon-6741c9f6acae8864701682/]Here is the easiest way to create numerical dummy data using pandas, and export them to CSV:
[crayon-6741c9f6acae9181710587/]Here is the pandas Demo Result in the Python GUI
By default, it will create 30 rows with 4 columns called A, B, C, and D and the index alpha-numeric. Here is the result:
Read this article to learn how to use Pandas for data analysis:
6. How do we use radar to generate dummy test data?
radar (RAndom DAte geneRation) is a Python library to generate random date.
Here is how you can install radar:
[crayon-6741c9f6acaea363215126/]The following code is the basic usage of radar:
[crayon-6741c9f6acaeb695026551/]radar with Python4Delphi Results
Are you ready to try these dummy data generators?
We have demonstrated 6 powerful Python libraries for creating dummy or test data – Faker, FauxFactory, lipsum, Mimesis, pandas, and radar. All of them are wrapped well inside a powerful GUI provided by Python4Delphi. We can’t wait to see what you build with Python4Delphi!
Want to know some more? Then check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi.