---json
{
"description": "This how-to shows you how to generate data from a list of values at random data with the column histogram generator.",
"low_quality_page": "false",
"page_id": "79stz1t3n9kfnabmfb8dm",
"title": "How to get data from a list of values at random"
}
---
====== Tabulify - How to get data from a list of values at random ======
===== About =====
This [[..:howto|how-to]] shows you how to generate data from a list of values at ''random'' data with the [[docs:generator:histogram|column histogram generator]].
Tip: The ''random column generator'' can also generate all primary data type (number, date, string) at random. See [[random]]
===== 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]] ''histogram_random--datagen.yml''
* has the [[docs:resource:logicalname|simple name]] ''histogram_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 named ''buckets_map'' with a [[docs:generator:histogram|histogram generator]] where the ''buckets'' property defines a map where:
* the key is the value to generate
* the value is the chance factor of generation (the more, the more chance that you get the value generated)
* has a column named ''buckets_list'' with a [[docs:generator:histogram|histogram generator]] where the ''buckets'' property defines:
* a list of values (the chance factor have by default a value of 1)
The two ''buckets'' columns (''buckets_map'' and ''buckets_list'') are equivalent.
They defines the ''buckets'' as being:
* a list of values
* with a factor of chance of value ''1''.
MaxRecordCount: 10
Columns:
- name: id
type: integer
comment: A id column to see easily the number of values generated
DataGenerator:
type: sequence
- name: bucket_map
type: varchar
comment: A column with a random color generator and a map of values with the chance factor
DataGenerator:
type: histogram
Buckets:
blue: 1
red: 1
green: 1
- name: bucket_list
type: varchar
comment: A column with a random color generator and a list of values
DataGenerator:
type: histogram
Buckets:
- blue
- red
- green
==== Printing the data ====
With the [[docs:tabli:data:print|data print command]], we can print the ''30 values'' generated.
tabli data print histogram_random--datagen.yml@howto
[[docs:connection:howto|howto]] is the connection that contains the files used in the [[..:howto|HowTo's]].
id bucket_map bucket_list
-- ---------- -----------
1 green blue
2 red blue
3 red green
4 green red
5 blue red
6 red red
7 green blue
8 red blue
9 green blue
10 green green
===== 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 ]]