Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

6 Simple Ways to Generate Dummy Data for Your Windows Apps

6 Simple Ways to Generate Dummy Data for Your Windows Apps hero image

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.

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:

https://blogs.embarcadero.com/web-scraping-6-ways-to-rapidly-collect-massive-datasets-in-your-windows-apps/

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.

https://www.youtube.com/watch?v=hjY6lBgrHhM

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.

Open Demo01.dproj.

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-6769a93c13e9e543345454/]

Don’t forget to put the path where your Faker library installed, to the System Environment Variables:

System Environment Variable Examples

[crayon-6769a93c13eaf115117876/]

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-6769a93c13eb3033268395/]

Here is the Faker output in the Python GUI:

Faker Demo with Python4Delphi in Windows.

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:

https://pythongui.org/tutorial-generate-python-dummy-data-and-plot-it-to-enterprise-grade-delphi-tchart/

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-6769a93c13eb6209694269/]

The following code is the implementation of FauxFactory to generate a random string, numeric, date, datetime, and email:

[crayon-6769a93c13eba511041039/]

Here are the FauxFactory examples in the Python GUI

FauxFactory Demo with Python4Delphi in Windows.

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-6769a93c13ebe138634210/]

Below is the code for generating random 100 words using lipsum (Run the following code inside the lower Memo of Python4Delphi Demo01 GUI):

[crayon-6769a93c13ec0049231267/]

lipsum Python4Delphi Results

lipsum Demo with Python4Delphi in Windows.

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:

First, here is how you can get Mimesis:

[crayon-6769a93c13ec2787199873/]

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-6769a93c13ec6253384121/]

Mimesis Simple yet Powerful Examples:

Mimesis Demo with Python4Delphi in Windows.

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-6769a93c13ec8915056962/]

Here is the easiest way to create numerical dummy data using pandas, and export them to CSV:

[crayon-6769a93c13ec9800673181/]

Here is the pandas Demo Result in the Python GUI

pandas Demo with Python4Delphi in Windows.

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:

https://pythongui.org/powerful-data-analysis-and-manipulation-using-pandas-library-in-a-delphi-windows-app/

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-6769a93c13ecc862748670/]

The following code is the basic usage of radar:

[crayon-6769a93c13ecd220851253/]

radar with Python4Delphi Results

radar Demo with Python4Delphi in Windows.

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.

Exit mobile version