Dynamic Columns
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.
Pass the dynamic columns that you want to add as an array input parameter to thesetDynamicColumns()
method while initializing the importer.
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.
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 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. | |
It specifies the data type of the incoming data. Possible values are: text, number, email, date, boolean, regex, ip, url, credit_card, phone_number, currency, list, dependent_list, dynamic_list, dependent_dynamic_list, multiselect_list, and multiselect_dynamic_list. | |
The validation rules for the data based on the column type. Validator options are mentioned below. | |
A default filler value for the column in case the incoming data is blank. | |
It indicates whether a column is mandatory. | |
It defines the display index of the column. Starts from 1. |
Validator options
Column Type | Validators | Example |
---|---|---|
text |
| "min_length": 2, "max_length": 50 |
number |
| "min_value": -2, "max_value": 100, "number_type": "integer", "allow_commas": true |
- | ||
date |
| "format": ["MM/DD/YYYY", "MM.DD.YYYY", "MM-DD-YYYY"] |
boolean | - | |
regex |
| "expression": "^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$" Note: The special characters in the expression need to be escaped. You may use a tool like this for escaping. |
ip |
| "version": “ipv4” |
url | - | |
credit_card | - | |
phone_number |
| "country_code": "de" |
currency |
Note: The array | "symbol": "$", "require_symbol": false, "allow_space_after_symbol": false, "symbol_after_digits": false, "allow_negatives": true, "parens_for_negatives": false, "negative_sign_before_digits": false, "negative_sign_after_digits": false, "thousands_separator": ",", "decimal_separator": ".", "allow_decimal": true, "require_decimal": false, "digits_after_decimal": 2, "allow_space_after_digits": false |
list |
| "values": [ {"value": "USA", "display_label": "USA", "dependents": [ {"value": "ny", "display_label": "New York"}, {"value": "ch", "display_label": "Chicago"}, {"value": "se", "display_label": "Seatle"}, {"value": "mi", "display_label": "Miami"} ]}, {"value": "Canada", "display_label": "Canada", "dependents": [ {"value": "to", "display_label": "Toronto"}, {"value": "va", "display_label": "Vancouver"} ]} ], "case_sensitive": false |
dependent_list |
| "primary_column": "countries" |
dynamic_list |
| "source_url": "https://api.myapp.com/countries", "request_method": "POST", "request_headers": [ {"key": "Content-Type", "value": "application/json"}, {"key": "X-Access-Token", "value": "71ab1d73a4d1319b260e9a0sdbdbc1c"} ], custom_user_attributes: true |
dependent_dynamic_list |
| "primary_column": "countries" |
multiselect_list |
| "values": ["Red", "Green", "Blue"], "delimiter": ".", "case_sensitive": false |
multiselect_dynamic_list |
| "source_url": "https://api.myapp.com/colors", "request_method": "POST", "request_headers": [ {"key": "Content-Type", "value": "application/json"}, {"key": "X-Access-Token", "value": "71ab1d73a4d1319b260e9a0sdbdbc1c"} ], "delimiter": "." |
Column Position
In general, the dynamic columns are displayed only after the regular columns.
The position
parameter helps to re-order the position of the dynamic columns and get them displayed before or in between the regular columns.
The position
value starts from 1 indicating the first position in the final column list. It is an optional parameter while defining the dynamic columns.
Receiving 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:
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.
S3 Data Destination
In the AWS S3 file store, the dynamic columns will be added as new columns in the uploaded file.
Last updated