Dynamic Columns
(Beta) Add new columns to the template at run-time.
Consider a scenario where you cannot have a fixed template for collecting data. The columns in the data model depend on the end user's preferences and/or some other criteria.
For such cases, csvbox provides the flexibility to add unique dynamic columns for each import at run-time.

Basic Installation

You can configure dynamic columns via the installation code.
Here's a basic configuration that adds 2 dynamic columns qualification and experience.
Javascript
React
Angular
Vuejs
Pass the dynamic columns that you want to add as an array input parameter to thesetDynamicColumns()method while initializing the importer.
1
importer.setDynamicColumns([
2
{
3
"column_name" : "qualification"
4
},
5
{
6
"column_name": "experience"
7
}
8
])
Copied!
Basic installation steps are available here.
Pass the dynamic columns as an object to the dynamicColumnsproperty of the CSVBoxButton component.
1
dynamicColumns={[
2
{
3
"column_name" : "qualification"
4
},
5
{
6
"column_name": "experience"
7
}
8
]}
Copied!
Basic installation steps are available here.
Add [dynamicColumns]="dynamicColumns" to the existing template.
1
@Component({
2
selector: 'app-root',
3
template: `
4
<csvbox-button
5
[licenseKey]="licenseKey"
6
[user]="user"
7
[dynamicColumns]="dynamicColumns"
8
[onImport]="onData.bind(this)">
9
Import
10
</csvbox-button>
11
`
12
})
Copied!
Then pass the dynamic columns as an object to thedynamicColumnsproperty of the AppComponent. Example:
1
dynamicColumns=[
2
{
3
column_name : "qualification"
4
},
5
{
6
column_name: "experience"
7
}
8
]
Copied!
Basic installation steps are available here.
Add :dynamicColumns="dynamicColumns" to the existing template.
1
<template>
2
<div id="app">
3
<CSVBoxButton
4
:licenseKey="licenseKey"
5
:user="user"
6
:dynamicColumns="dynamicColumns"
7
:onImport="onImport">
8
Upload File
9
</CSVBoxButton>
10
</div>
11
</template>
Copied!
Pass the dynamic columns as an object to thedynamicColumnsproperty of theCSVBoxButton component. Example:
1
dynamicColumns: [
2
{
3
column_name : "qualification"
4
},
5
{
6
column_name: "experience"
7
}
8
]
Copied!
Basic installation steps are available here.
Dynamic columns will be visible in the importer along with the other regular columns.

Advanced Configuration

Dynamic columns can be configured by passing additional<key>: <value>pairs to the array input parameter of thesetDynamicColumns()method.
Here is an example illustrating more configuration options.
Javascript
React
Angular
Vuejs
1
importer.setDynamicColumns([
2
{
3
"column_name" : "qualification",
4
"display_label": "Highest Qualification",
5
"info_hint": "What is your highest educational degree",
6
"matching_keywords": "degree, education",
7
"type": "text",
8
"validators":
9
{
10
"min_length": 2,
11
"max_length": 50
12
},
13
"required": true
14
},
15
{
16
"column_name": "experience",
17
"display_label": "Work Experience",
18
"info_hint": "Years of work experience",
19
"matching_keywords": "",
20
"type": "number",
21
"validators":
22
{
23
"min_value": 0,
24
"max_value": 100
25
},
26
"required": false
27
},
28
{
29
"column_name": "gender",
30
"display_label": "Gender",
31
"info_hint": "",
32
"matching_keywords": "",
33
"type": "list",
34
"validators":
35
{
36
"values": [
37
{"value": "m", "display_label": "male"},
38
{"value": "f", "display_label": "female"}
39
],
40
"case_sensitive": false
41
},
42
"required": true
43
}
44
])
Copied!
1
dynamicColumns={[
2
{
3
"column_name" : "qualification",
4
"display_label": "Highest Qualification",
5
"info_hint": "What is your highest educational degree",
6
"matching_keywords": "degree, education",
7
"type": "text",
8
"validators":
9
{
10
"min_length": 2,
11
"max_length": 50
12
},
13
"required": true
14
},
15
{
16
"column_name": "experience",
17
"display_label": "Work Experience",
18
"info_hint": "Years of work experience",
19
"matching_keywords": "",
20
"type": "number",
21
"validators":
22
{
23
"min_value": 0,
24
"max_value": 100
25
},
26
"required": false
27
},
28
{
29
"column_name": "gender",
30
"display_label": "Gender",
31
"info_hint": "",
32
"matching_keywords": "",
33
"type": "list",
34
"validators":
35
{
36
"values": [
37
{"value": "m", "display_label": "male"},
38
{"value": "f", "display_label": "female"}
39
],
40
"case_sensitive": false
41
},
42
"required": true
43
}
44
]}
Copied!
1
dynamicColumns=[
2
{
3
column_name : "qualification",
4
display_label: "Highest Qualification",
5
info_hint: "What is your highest educational degree",
6
matching_keywords: "degree, education",
7
type: "text",
8
validators":
9
{
10
min_length: 2,
11
max_length: 50
12
},
13
required: true
14
},
15
{
16
column_name: "experience",
17
display_label: "Work Experience",
18
info_hint: "Years of work experience",
19
matching_keywords: "",
20
type: "number",
21
"validators:
22
{
23
min_value: 0,
24
max_value: 100
25
},
26
required: false
27
},
28
{
29
column_name: "gender",
30
display_label: "Gender",
31
info_hint: "",
32
matching_keywords: "",
33
type: "list",
34
validators:
35
{
36
values: [
37
{value: "m", display_label: "male"},
38
{value: "f", display_label: "female"}
39
],
40
case_sensitive: false
41
},
42
required: true
43
}
44
]
Copied!
1
dynamicColumns: [
2
{
3
column_name : "qualification",
4
display_label: "Highest Qualification",
5
info_hint: "What is your highest educational degree",
6
matching_keywords: "degree, education",
7
type: "text",
8
validators":
9
{
10
min_length: 2,
11
max_length: 50
12
},
13
required: true
14
},
15
{
16
column_name: "experience",
17
display_label: "Work Experience",
18
info_hint: "Years of work experience",
19
matching_keywords: "",
20
type: "number",
21
"validators:
22
{
23
min_value: 0,
24
max_value: 100
25
},
26
required: false
27
},
28
{
29
column_name: "gender",
30
display_label: "Gender",
31
info_hint: "",
32
matching_keywords: "",
33
type: "list",
34
validators:
35
{
36
values: [
37
{value: "m", display_label: "male"},
38
{value: "f", display_label: "female"}
39
],
40
case_sensitive: false
41
},
42
required: true
43
}
44
]
Copied!
column_name is the only key that is mandatory for adding a dynamic column.

Configuration Options

Key
Description
It is the column name that will be pushed to the data destination.
The user-friendly column label that the users will see in the importer.
info_hint
Info Hints are help tooltips that will get displayed when the users hover the mouse over the Display Label (or click it) in the importer.
Comma-separated set of keywords as alternative matching options to help users match column names automatically.
type
It specifies the data type of the incoming data. Possible values are: text, number, email, date, boolean, regex, ip, url, credit_card, phone_number and list.
validators
The validation rules for the data based on the column type. Validator options are mentioned below.
required
It indicates whether a column is mandatory.

Validator options

Column Type
Validators
Example
text
  1. 1.
    min_length
  2. 2.
    max_length
"min_length": 2,
"max_length": 50
number
  1. 1.
    min_value
  2. 2.
    max_value
"min_value": -2,
"max_value": 100
email
-
date
  1. 1.
    format
"format": “MM/DD/YYYY”
boolean
-
regex
  1. 1.
    expression
"expression": "^[\\w-\\.][email protected]([\\w-]+\\.)+[\\w-]{2,4}quot;
Note: The special characters in the expression need to be escaped. You may use a tool like this for escaping.
ip
  1. 1.
    version
"version": “ipv4”
url
-
credit_card
-
phone_number
-
list
  1. 1.
    values
  2. 2.
    case_sensitive
"values": [
{"value": "m", "display_label": "male"},
{"value": "f", "display_label": "female"},
],
"case_sensitive": false

Displaying Dynamic Data

The data from the dynamic columns is available in the data destinations along with the data from the regular columns. Currently, dynamic columns are supported by the following destinations only:
  1. 1.
  2. 2.
    Amazon S3

API/Webhook Data Destination

In the API response JSON object, the dynamic data will be displayed inside the _dynamic_data object as shown below. The _dynamic_data object will be visible only if the dynamic columns are configured for the import. In the example below check lines 12 and 31.
1
[
2
{
3
"import_id": 79418895,
4
"sheet_id": 55,
5
"sheet_name": "Products",
6
"row_number": 1,
7
"row_data": {
8
"Name": "TP-Link TL-WN822N Wireless N300 High Gain USB Adapter",
9
"SKU": "AS-100221",
10
"Price": "33.00",
11
"Quantity": "3",
12
"_dynamic_data":{
13
"qualification": "MBA",
14
"experience": "3"
15
}
16
},
17
"custom_fields": {
18
"user_id": "1002"
19
}
20
},
21
{
22
"import_id": 79418895,
23
"sheet_id": 55,
24
"sheet_name": "Products",
25
"row_number": 2,
26
"row_data":{
27
"Name": "EPower Technology EP-600PM Power Supply 600W ATX12V 2.3 Single 120mm Cooling Fan Bare",
28
"SKU": "AS-103824",
29
"Price": "95.35",
30
"Quantity": "8",
31
"_dynamic_data":{
32
"qualification": "MA",
33
"experience": "6"
34
}
35
},
36
"custom_fields": {
37
"user_id": "1002"
38
}
39
},
40
]
41
Copied!

S3 Data Destination

In the AWS S3 file store, the dynamic columns will be added as new columns in the uploaded file.
Last modified 1mo ago