Apply Your Own Data
If you are creating a new feature to your existing product, you may need to generate new data based on your existing data. Our platform allow you to upload your own data through a csv file and apply data generation upon it.
This feature is also useful when you want to generate data for different scenarios. In this case, you can output a csv file through our service first then use it as boilerplate for your next data generations.
Example
Here is an example of how to create customer records based on a csv file that contains 50 records of customer data.
Prepare CSV File
The my_data.csv used in this example can either be generated using following schema and plan files:
A pre-generated csv file can be downloaded from the following link:
Generate Customer Records
Define my_data Entity
To generate new records based on the csv file, you have to define an entity my_data in your schema file which should have properties matching your csv headers.
entities:
- name: "my_data"
properties:
- name: "id"
type: "text"
- name: "first_name"
type: "text"
- name: "last_name"
type: "text"
- name: "email"
type: "text"
The entity name has to be lowercase "my_data" for our platform to use your csv file.
Define Mapping
To use the records in the csv file, you can use any properties in my_data
as a reference in your other entities.
If you want to ensure all the records are used, you can define a one to one mapping by applying same records count and loop
reference strategy in your target entity.
- Define Reference
- Define One to One Mapping
- Optional Output Control
- name: "customer"
properties:
- name: "id"
type: "sequence"
index:
id: 0
- name: "customer_id"
type: "text"
reference:
entity: "my_data"
property: "id"
linked: "id"
- name: "first_name"
type: "text"
reference:
entity: "my_data"
property: "first_name"
linked: "id"
- name: "last_name"
type: "text"
reference:
entity: "my_data"
property: "last_name"
linked: "id"
- name: "email"
type: "text"
reference:
entity: "my_data"
property: "email"
linked: "id"
- name: "username"
type: "text"
- name: "name"
type: "text"
- name: "password"
type: "text"
- entity: "customer"
count: 50
properties:
- name: "customer_id"
referenceStrategy: "loop"
entities:
- name: "customer"
properties:
- name: "first_name"
hide: true
- name: "last_name"
hide: true
- name: "customer_id"
hide: true
Apart from the csv file, the other files used for this generation can be downloaded from the following links:
Format Conversion
As a side effect (bonus) of applying your own data, you can also convert your csv files into other formats. To use it, you have to define an extra entity to satisfy our validation process.
- Define Entity ignore
- Define ignore Record Count
name: "user_data_convert_sample"
entities:
- name: "my_data"
properties:
- name: "id"
type: "text"
- name: "first_name"
type: "text"
- name: "last_name"
type: "text"
- name: "email"
type: "text"
- name: "ignore"
properties:
- name: "id"
type: "sequence"
data:
- entity: "ignore"
count: 1
The following are sample files used to convert the sample csv file