---json
{
"description": "This how-to shows you how to generate random data with the column random generator.",
"low_quality_page": "false",
"page_id": "bi8ermzs2ogeyim4vvnxd"
}
---
====== Tabulify - How to generate random data ======
===== About =====
This [[..:howto|how-to]] shows you how to generate ''random'' data with the [[docs:generator:random|column random generator]].
===== Steps =====
==== Creation of the generator file ====
To generate data, you need to create a [[docs:resource:generator|generator file]] that will describe the data to be generated.
The below [[docs:resource:generator|data resource generator]]:
* has the [[docs:resource:name|name]] ''random--generator.yml''
* has the [[docs:resource:logical_name|logical name]] ''random''
* will generate ''30'' values (''MaxRecordCount'' count)
* has a column named ''id'' that has [[docs:generator:sequence|sequence data generator]] that:
* starts by default at the value ''1''
* increments by default with the value ''1''
* has a column for each data type with a [[docs:generator:random|random generator]] where the range is defined by:
* a ''max''
* and a ''min''
kind: generator
spec:
MaxRecordCount: 30
Columns:
- name: id
type: integer
comment: A id column to see easily the number of values generated
data-supplier:
type: sequence
- name: int
type: integer
comment: A column with a random integer generator and a step
data-supplier:
type: random
arguments:
min: 0
max: 10
step: 2
- name: rand_float
type: float
comment: A column with a random float generator
data-supplier:
type: random
arguments:
min: 0.0
max: 8.0
- name: rand_double
type: double
comment: A column with a random double generator
data-supplier:
type: random
arguments:
min: 0.0
max: 8.0
- name: numeric
type: numeric
scale: 2
comment: A column with a random numeric generator with a scale of 2
data-supplier:
type: random
arguments:
min: 10.40
max: 19.50
- name: rand_date
type: date
comment: A column with a random date generator
data-supplier:
type: random
arguments:
min: 2020-10-01
max: 2020-11-01
step: 1
- name: rand_timestamp
type: timestamp
comment: A column with a random timestamp generator
data-supplier:
type: random
arguments:
min: 2020-10-01 01:00:00
max: 2020-10-01 02:00:00
step: 1000
- name: rand_time
type: time
comment: A column with a random time generator
data-supplier:
type: random
arguments:
min: 01:00:00
max: 02:00:00
step: 5000
- name: string
type: varchar
comment: A column with a random string
data-supplier:
type: random
arguments:
min: a
max: zzzzzzzz
==== Printing the data ====
With the [[docs:tabul:data:print|data print command]], we can print the ''30 values'' generated.
tabul data print random--generator.yml@howto
[[docs:connection:howto|howto]] is the connection that contains the files used in the [[..:howto|HowTo's]].
id int rand_float rand_double numeric rand_date rand_timestamp rand_time string
-- --- ---------- ----------- ------- ---------- --------------------- --------- ------
1 6 6.0 7.0 13.40 2020-10-13 2020-10-01 01:15:51.0 01:36:10 f1Mce
2 2 2.0 7.0 19.40 2020-10-29 2020-10-01 01:28:20.0 01:41:50 lJQ5y
3 2 2.0 5.0 14.40 2020-10-26 2020-10-01 01:40:45.0 01:22:25 gR45E
4 10 1.0 1.0 14.40 2020-10-23 2020-10-01 01:11:44.0 01:35:25 pDsWA
5 6 1.0 6.0 12.40 2020-10-12 2020-10-01 01:48:14.0 01:53:45 iYg52
6 0 4.0 1.0 13.40 2020-10-10 2020-10-01 01:30:47.0 01:25:45 p2qaX
7 10 4.0 1.0 16.40 2020-10-07 2020-10-01 01:53:45.0 01:27:55 lY3GQ
8 6 3.0 8.0 11.40 2020-10-13 2020-10-01 01:06:23.0 01:06:15 bivm2
9 0 8.0 3.0 12.40 2020-10-02 2020-10-01 01:39:57.0 01:57:45 dBrp2
10 10 6.0 2.0 17.40 2020-10-29 2020-10-01 01:37:24.0 01:18:20 cNSaI
11 8 7.0 4.0 19.40 2020-10-02 2020-10-01 01:50:59.0 01:49:00 iFV6D
12 4 8.0 7.0 14.40 2020-10-26 2020-10-01 01:42:58.0 01:50:00 klnvp
13 0 5.0 0.0 10.40 2020-10-25 2020-10-01 01:37:40.0 01:43:05 rtUXY
14 4 8.0 5.0 13.40 2020-10-04 2020-10-01 01:58:42.0 01:02:00 dpJEq
15 4 0.0 0.0 10.40 2020-10-31 2020-10-01 01:07:38.0 01:24:30 g6JCU
16 2 5.0 7.0 15.40 2020-10-10 2020-10-01 01:21:15.0 01:58:30 d9j2Z
17 4 6.0 5.0 13.40 2020-11-01 2020-10-01 01:30:51.0 01:10:20 bw7Lm
18 6 5.0 2.0 15.40 2020-10-02 2020-10-01 01:56:10.0 01:41:10 oHbw6
19 0 2.0 4.0 16.40 2020-10-26 2020-10-01 01:06:36.0 01:20:35 cVSPP
20 0 7.0 5.0 14.40 2020-10-07 2020-10-01 01:46:14.0 01:37:10 hWQOU
21 6 8.0 8.0 15.40 2020-10-05 2020-10-01 01:33:25.0 01:43:00 cZDQY
22 10 7.0 2.0 12.40 2020-10-15 2020-10-01 01:03:21.0 01:12:35 hzOKb
23 8 7.0 0.0 19.40 2020-11-01 2020-10-01 01:00:00.0 01:21:35 q11vJ
24 4 1.0 0.0 18.40 2020-10-25 2020-10-01 01:26:01.0 01:16:25 booEw
25 0 5.0 1.0 17.40 2020-10-04 2020-10-01 01:35:59.0 01:33:20 k8EHE
26 0 2.0 1.0 17.40 2020-10-24 2020-10-01 01:13:17.0 01:33:30 d8HjX
27 6 8.0 2.0 19.40 2020-10-24 2020-10-01 01:46:01.0 01:13:00 c1kLn
28 8 1.0 4.0 17.40 2020-10-01 2020-10-01 01:33:34.0 01:23:10 eAEIQ
29 0 0.0 1.0 14.40 2020-10-11 2020-10-01 01:20:13.0 01:44:30 eb91H
30 6 4.0 2.0 17.40 2020-10-07 2020-10-01 01:52:25.0 01:38:15 rH1lT
===== Next =====
Because a [[docs:resource:generator|generator]] is just a [[docs:resource:resource|data resource]], you can use it in every [[docs:op:op|data operation]].
[[generator_data_operation|How to use a generator in a data operation ]]