Skip to main content
Sometimes you can’t use a fixed template to collect data, because the columns in the data model depend on the end user’s preferences or other criteria. For these cases, CSVbox lets you add unique dynamic columns to each import at run time.

Basic installation

Configure dynamic columns in the installation code. Here’s a basic configuration that adds 2 dynamic columns, qualification and experience.
Pass the dynamic columns you want to add as an array input parameter to the setDynamicColumns() method while initializing the importer.
Basic installation steps are available here.
Dynamic columns are visible in the importer along with the other regular columns.

Advanced configuration

Configure dynamic columns further by passing additional <key>: <value> pairs to the array input parameter of the setDynamicColumns() method. Here is an example illustrating more configuration options.
column_name is the only mandatory key for adding a dynamic column.

Configuration options

Validator options

Column TypeValidatorsExample
text
  1. min_length
  2. max_length

”min_length”: 2,

“max_length”: 50

number
  1. min_value
  2. max_value
  3. number_type
    - Valid values: “any”, “integer”
    - Default: “any”
  4. allow_commas
    - Valid values: true, false
    - Default: false
  5. excel_value
    - Valid values: “raw”, “formatted”
    - Default: “formatted”

“min_value”: -2,

“max_value”: 100,
“number_type”: “integer”,
“allow_commas”: true,
“excel_value”: “raw”

email-
date
  1. format
”format”: [“MM/DD/YYYY”, “MM.DD.YYYY”, “MM-DD-YYYY”]
time
  1. format
”format”: [“h:mm:ss”,“hh:mm:ss”]
boolean-
regex
  1. expression
  2. error_message

”expression”: ”^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$”,
“error_message”: “Invalid format”

Note: The special characters in the expression need to be escaped. You may use a tool like this for escaping.

ip
  1. version
”version”: “ipv4”
url-
credit_card-
phone_number
  1. country_code
”country_code”: “de”
currency
  1. symbol
  2. require_symbol
  3. allow_space_after_symbol
  4. symbol_after_digits
  5. allow_negatives
  6. parens_for_negatives
  7. negative_sign_before_digits
  8. negative_sign_after_digits
  9. thousands_separator
  10. decimal_separator
  11. allow_decimal
  12. require_decimal
  13. digits_after_decimal
  14. allow_space_after_digits

Note: The array digits_after_decimal is filled with the exact number of digits allowed, not a range. For example, a range of 1 to 3 will be given as [1, 2, 3].

“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
  1. values

    • value
    • display_label (optional)
    • dependents (optional)

      • value
      • display_label
  2. case_sensitive
  3. other_values (Optional. Default is false)
  4. accept_list_values
    (Optional. Default is false)

“values”: [

{“value”: “USA”, “display_label”: “USA”, “dependents”: [ {“value”: “ny”, “display_label”: “New York”}, {“value”: “ch”, “display_label”: “Chicago”}, {“value”: “se”, “display_label”: “Seattle”}, {“value”: “mi”, “display_label”: “Miami”} ]}, {“value”: “Canada”, “display_label”: “Canada”, “dependents”: [ {“value”: “to”, “display_label”: “Toronto”}, {“value”: “va”, “display_label”: “Vancouver”}
]}

],

“case_sensitive”: false,
“other_values”: false,
“accept_list_values”: true

dependent_list
  1. primary_column
”primary_column”: “countries”
dynamic_list
  1. source_url
  2. request_method
  3. request_headers
  4. custom_user_attributes (Optional. Default is true)
  5. other_values (Optional. Default is false)

“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,
“other_values”: false

dependent_dynamic_list
  1. primary_column
”primary_column”: “countries”
multiselect_list
  1. values
  2. delimiter (Optional. Default is comma ”,“)
  3. case_sensitive
  4. other_values (Optional. Default is false)

“values”: [“Red”, “Green”, “Blue”],

“delimiter”: ”.”,
“case_sensitive”: false,
“other_values”: false

multiselect_dynamic_list
  1. source_url
  2. request_method
  3. request_headers
  4. delimiter (Optional. Default is comma ”,“)
  5. other_values (Optional. Default is false)

“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”: ”.”,
“other_values”: false

Column position

By default, dynamic columns are displayed after the regular columns. The position parameter re-orders the dynamic columns so they display before or in between the regular columns. The position value starts from 1, which indicates the first position in the final column list. It is an optional parameter when defining dynamic columns.

Receiving dynamic data

Data from dynamic columns is available in the data destinations along with the data from the regular columns. Currently, dynamic columns are supported only by the following destinations:

API/Webhook data destination

In the API response JSON object, the dynamic data appears inside the _dynamic_data object, as shown below. The _dynamic_data object is visible only if 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, dynamic columns are added as new columns in the uploaded file.