How to generate random data

About

This how-to shows you how to generate random data with the column random generator.

Steps

Creation of the generator file

To generate data, you need to create a generator file that will describe the data to be generated.

The below data resource generator:

  • has the name random–datagen.yml
  • has the logical name random
  • will generate 30 values (MaxRecordCount count)
  • has a column named id that has 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 random generator where the range is defined by:
    • a max
    • and a min
MaxRecordCount: 30
Columns:
  - name: id
    type: integer
    comment: A id column to see easily the number of values generated
    DataGenerator:
      type: sequence
  - name: int
    type: integer
    comment: A column with a random integer generator
    DataGenerator:
      type: random
      min: 0
      max: 5
  - name: rand_float
    type: float
    comment: A column with a random float generator
    DataGenerator:
      type: random
      min: 0.0
      max: 8.0
  - name: rand_double
    type: double
    comment: A column with a random double generator
    DataGenerator:
      type: random
      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
    DataGenerator:
      type: random
      min: 10.40
      max: 19.50
  - name: rand_date
    type: date
    comment: A column with a random date generator
    DataGenerator:
      type: random
      min: 2020-10-01
      max: 2020-11-01
  - name: rand_timestamp
    type: timestamp
    comment: A column with a random timestamp generator
    DataGenerator:
      type: random
      min: 2020-10-01 01:00:00
      max: 2020-10-01 02:00:00
  - name: rand_time
    type: time
    comment: A column with a random time generator
    DataGenerator:
      type: random
      min: 01:00:00
      max: 02:00:00
  - name: string
    type: varchar
    comment: A column with a random string
    DataGenerator:
      type: random
      min: a
      max: zzzzzzzz



Printing the data

With the data print command, we can print the 30 values generated.

tabli data print random--datagen.yml@howto

howto is the connection that contains the files used in the HowTo's.

id   int   rand_float            rand_double   numeric   rand_date    rand_timestamp          rand_time   string
--   ---   ----------   --------------------   -------   ----------   ---------------------   ---------   -------
 1     2     5.949046      7.334240632976011     13.45   2020-10-16   2020-10-01 01:04:55.0   01:59:23    dtwdqtt
 2     0    3.8458169      6.917470410239475     17.37   2020-10-24   2020-10-01 01:41:48.0   01:47:56    cgzfbxu
 3     1    0.5151166      5.894278028908796     12.24   2020-10-09   2020-10-01 01:31:37.0   01:47:29    dddulee
 4     5    3.6544273      2.066366806912213     17.14   2020-10-19   2020-10-01 01:14:46.0   01:30:43    bykdzlk
 5     3    7.9282465     3.0814429269694026     10.58   2020-10-25   2020-10-01 01:55:19.0   01:07:57    dyuwnpc
 6     2    5.1251993      7.137018598795309     12.02   2020-10-19   2020-10-01 01:36:52.0   01:37:29    qaamnu
 7     3     6.811733      7.075330683806021     19.23   2020-10-22   2020-10-01 01:07:47.0   01:24:05    bsdkorp
 8     3     5.513641     3.1506205452746663     18.31   2020-10-30   2020-10-01 01:48:43.0   01:43:08    ehybxhr
 9     0    2.4566748     3.7500275924077826     12.35   2020-10-08   2020-10-01 01:30:04.0   01:22:16    cquufuo
10     1     7.897481     3.3493473476849323     16.95   2020-10-30   2020-10-01 01:01:59.0   01:27:40    evqqzko
11     1    2.0761254     0.9849009627000829     18.79   2020-10-08   2020-10-01 01:54:58.0   01:17:14    drivpgo
12     1     6.821446      4.522769574847222     13.68   2020-10-19   2020-10-01 01:03:28.0   01:37:39    eapctsw
13     2    3.8404908   0.006640847321239818     15.76   2020-10-24   2020-10-01 01:40:22.0   01:57:26    exdmzpm
14     5    5.7232847     3.3655195946604524     13.10   2020-10-26   2020-10-01 01:45:08.0   01:23:08    cxvjoh
15     2    3.6941814     1.7625506111621627     11.69   2020-10-24   2020-10-01 01:43:17.0   01:20:47    bjhzeaa
16     3    6.1410446     1.8662069753044594     11.21   2020-10-05   2020-10-01 01:09:54.0   01:19:38    spgmkf
17     2     7.953512      4.325088311622337     13.35   2020-10-05   2020-10-01 01:44:58.0   01:10:29    cniianx
18     3     4.701595      5.727585561426775     11.06   2020-10-23   2020-10-01 01:43:18.0   01:45:23    degzpaf
19     5    7.6858525       3.32765728025669     18.30   2020-10-24   2020-10-01 01:36:43.0   01:01:13    exqsund
20     5    1.8904049     3.8179689470575786     11.40   2020-10-27   2020-10-01 01:01:09.0   01:43:53    bkpvwot
21     4    6.8700266      7.431647395929477     19.09   2020-10-21   2020-10-01 01:36:39.0   01:25:31    dbrggrx
22     4     2.602568      4.653896192996839     18.40   2020-10-29   2020-10-01 01:42:48.0   01:21:37    blnylqi
23     1     4.337965     0.8247261554054965     14.56   2020-10-22   2020-10-01 01:07:16.0   01:30:22    eziyogv
24     4     4.475076      5.914048325115427     12.18   2020-10-27   2020-10-01 01:00:31.0   01:51:03    bopwkug
25     3     5.497604     0.7503798394018828     14.64   2020-10-05   2020-10-01 01:03:56.0   01:34:01    dlvucsv
26     4     2.000347     4.9844142426633775     18.34   2020-10-28   2020-10-01 01:14:36.0   01:48:48    bsnunad
27     4    3.8370354     6.0687039992400695     15.92   2020-10-20   2020-10-01 01:44:08.0   01:13:06    dpnufcq
28     5    2.4209976      6.534706692236394     15.98   2020-10-30   2020-10-01 01:04:20.0   01:19:08    dknrrah
29     3    0.2099089     0.8484447542140581     16.18   2020-10-03   2020-10-01 01:27:40.0   01:29:57    xgywvt
30     2     1.405872      7.126028009377373     14.42   2020-10-08   2020-10-01 01:44:51.0   01:12:35    csnmnga

Next

Because a generator is just a data resource, you can use it in every data operation.

How to use a generator in a data operation




Related Pages
Undraw Data Processing
How to generate data with the Tabulify Data Generator

A collection of how-to's to get the in and out of the Tabulify Data Generator
Undraw Data Processing
Random Data Generator

A random generator is a column data generator that generates data randomly inside a range of values. histogram generator1 This generator will generate the values in an uniform distribution. Key...
Undraw Data Processing
How to get data from a list of values at random

This how-to shows you how to generate data from a list of values at random data with the column histogram generator.

Task Runner