Skip to main content

Introduction

D-Thok is a python package to generate mock Test data in csv, json and xml format which can be used for any Mock Service, Performance Testing etc. It required input parameter as schema file where required structure is defined with data type, number of records, required format and file name.

Index

Setup Installation | Execution
Input Data Type alphabets | alpha-numeric | numeric | code | title | firstName | lastName | date_of_birth | choices | PhoneNumber | email | streetName | postcode | country | city | date | company | boolean | accountNumber | constant
Output File Format csv | json | xml

Input Datatype

Required input schema definition have to provided with all required Field name and required datatype in JSON format. Here is Sample input Schema definition file,

[
	{
	  "EmployeeID" 		: "code||PALO-%%-##LTD!@",
	  "Salutation"	   	: "alphabet||title",
	  "Firstname"  		: "alphabet|20|firstName",
	  "Lastname"   		: "alphabet|20|lastName",
	  "DOB"		   	: "date_of_birth|MinAge=30,MaxAge=40|%m-%d-%Y",
	  "Gender"	   	: "choices|('Male', 'Female')|",
	  "Mobile"     		: "PhoneNumber||India",
	  "emailId"	   	: "alphanum||email",
	  "Address"    		:
	  {

            "AddressType"   : "choices|('RES', 'OFF', 'WRK')|",
	    "Street-1"      : "alphabet|20|streetName",
	    "Street-2"      : "alphanum|20|streetName",
	    "Postalcode"    : "numeric|6|postcode",
	    "country"	    : "alphabet||country",
	    "city"	    : "alphabet||city"
	  },
	  "DOJ"		  	: "date|StartDate=20100223,EndDate=20200330|%Y-%m-%d",
	  "Client"	  	: "alphabet||company",
	  "Active"		: "boolean||",
	  "AccountNum"		: "alphanum|NONE|accountNumber",
	  "Salary"	    	: "constant|Monthly|",
          "DeskNumber"	    	: "constant|null|"
	}
]

Below are the sample data type syntax that can be used in input file.

alphabets

To generate random alphabetic String

Syntax:

"<Node Name>" : "alphabet|<length>"

e.g.

"ProductName" : "alphabet|30"

alphanum

To generate random alphanumeric String

Syntax:

"<Node Name>" : "alphanum|<length>"

e.g.

"ProductNumber" : "alphanum|30"

numeric

To generate random numeric value

Syntax:

"<Node Name>" : "numeric|<length>"

e.g.

"ProductID" : "numeric|30"

code

If you want to generate a code with some Prefix String

Syntax:

"<Node Name>" : "code||<Prefix String><regex>"
  • Number signs (‘#’) are replaced with a random digit (0 to 9)
  • Number signs (‘#’) are replaced with a random digit (0 to 9)
  • Percent signs (‘%’) are replaced with a random non-zero digit (1 to 9)
  • Exclamation marks (‘!’) are replaced with a random digit or an empty string
  • At symbols (‘@’) are replaced with a random non-zero digit or an empty string

e.g.

"EmployeeID" : "code||PALO-%%-##LTD!@"

Output: 
"EmployeeID": "PALO-26-12LTD8"

title

To generate random salutations like Dr. or Mr. or Mrs. or Mx.

Syntax:

"<Node Name>" : "alphabet||title"

e.g.

"Salutation" : "alphabet||title"

Output: 
"Salutation": "Mr."

firstName

Use to generate random firstName

Syntax:

"<Node Name>" : "alphabet|<Max length>|firstName"

e.g.

"Firstname" : "alphabet|20|firstName",

Output: 
"Firstname": "Samantha"

lastName

Use to generate random lastname

Syntax:

"<Node Name>" : "alphabet|<Max length>|lastName"

e.g.

"LastName" : "alphabet|20|lastName"

Output: 
"LastName": "Daniel"

date_of_birth

Use to generate random date_of_birth

Syntax:

"<Node Name>" : "date_of_birth|MinAge=<age>,MaxAge=<age>|<DateFormat>"

e.g.

"DOB" : "date_of_birth|MinAge=30,MaxAge=40|%m-%d-%Y"

Output: 
"DOB": "04-14-1981"

choices

If we want to select a value randomly from given choices

Syntax:

"<Node Name>" : "choices|(<'value1', 'value2'>)|"

e.g.

"AddressType": "choices|('RES', 'OFF', 'WRK')|"

Output: 
"AddressType": "RES"

PhoneNumber

Random Phone Number based on country

Syntax:

"<Node Name>" : "PhoneNumber||<Country Name>"

e.g.

"Mobile" : "PhoneNumber||India"

Output: 
"Mobile": "+917880010426"

email

Random Email Address

Syntax:

"<Node Name>" : "alphanum||email"

e.g.

"emailId" : "alphanum||email"

Output: 
"emailId": "ncooper@hopkins.com"

streetName

Random Street Address Name

Syntax:

"<Node Name>" : "alphabet|<length>|streetName"

e.g.

"Street-1": "alphabet|20|streetName"

Output: 
"Street-1": "Douglas Crossing"

postcode

Random postcode

Syntax:

"<Node Name>" : "numeric|<length>|postcode"

e.g.

"Postalcode": "numeric|6|postcode"

Output: 
"Postalcode": "20494"

country

Random country

Syntax:

"<Node Name>" : "alphabet||country"

e.g.

"country": "alphabet||country"

Output: 
"country": "Singapore"

city

Random city

Syntax:

"<Node Name>" : "alphabet||city"

e.g.

"City": "alphabet||city"

Output: 
"city": "Bangalore"

date

Generate Random Date between two date

Syntax:

"<Node Name>" : "date|StartDate=<date in yyyyMMdd>,EndDate=<date in yyyyMMdd>|<required Date Format>"

e.g.

"DOJ": "date|StartDate=20100223,EndDate=20200330|%Y-%m-%d"

Output: 
"DOJ": "2011-07-04"

company

Generate Random Company Name

Syntax:

"<Node Name>" : "alphabet||company"

e.g.

"Client": "alphabet||company"

Output: 
"Client": "Williams-Harris"

boolean

Randomly choose boolean value

Syntax:

"<Node Name>" : "boolean||"

e.g.

"Active": "boolean||"

Output: 
"Active": "False"

accountNumber

Generate random Basic or Internal account number

Syntax:

"<Node Name>" : "alphanum|<Account Type>|accountNumber" 
  • NONE - Generate a Basic Bank Account Number (BBAN)
  • Internal - Generate an International Bank Account Number (IBAN)

e.g.

"AccountNum": "alphanum|NONE|accountNumber"

Output: 
"AccountNum": "JRMR05894987945503"

constant

If you want to use Constant values for all the records

Syntax:

"<Node Name>" : "constant|<Required Value>|"
  • NONE - Generate a Basic Bank Account Number (BBAN)
  • Internal - Generate an International Bank Account Number (IBAN)

e.g.

"Salary": "constant|Monthly|"

Output: 
"Salary": "Monthly"

Installation

Run the following to install:

pip install dthok

Note: Python version should be >=3.6

Execution

  • Command structure to generate required bulk file,
dthok -f <input Payload file path> -n <No. of Records> -fmt <Output file format (csv, json or xml)> -o <Output file name>

For Example:

dthok -f  /test1.json -n  10 -fmt  json -o MyTestData

Metadata

Release files for dthok 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dthok 1.0.0
File Size Uploaded Provenance Actions
dthok-1.0.0.tar.gz 7.3 kB Without provenance Details for dthok-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dthok 1.0.0
File Interpreter ABI Platform Actions
dthok-1.0.0-py2-none-any.whl Python 2 none any Details for dthok-1.0.0-py2-none-any.whl

Total release size: 15.4 kB

Release files / dthok-1.0.0.tar.gz

Download URL dthok-1.0.0.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bae3b33749c60614535ff549109fc0856511a45f30bbedaad603c4b9fbc9c5d6
BLAKE2b-256 checksum
How to use checksums
08d0a1faa4bf28f96d4be09f33ed75b38ea1331933f7b9b612e63791335fe3f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

Release files / dthok-1.0.0-py2-none-any.whl

Download URL dthok-1.0.0-py2-none-any.whl
Size 8.1 kB
Tags Python 2
SHA-256 checksum
How to use checksums
f1fd5c01437f82300990f753d781d56fb0d61cdc072b617fe6ed72feda612920
BLAKE2b-256 checksum
How to use checksums
1fbf11f347ded7c0080eba9a042f73cb9e3e1adf83d071c4bf1bc915b70d41c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

Security for dthok 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page