Skip to content
v2.7 (latest)

Create a Constant Table from a CSV File ​

Instead of manually creating a Constant table, you can also drag and drop a CSV file on it.

Requirements ​

The following rules apply to CSV files:

  • The file should have a header row
  • Each row should have values separated by a comma
  • If a value represents a number, do not add quotes
  • If a value represents a string, add quotes to the value

An example CSV file:

key,   value1, value2
"aaa",  2,      5
"bbb",  3,      6
"ccc",  8,      10

Procedure ​

  1. Create a new Constant and set its Constant type to Table.
  2. Drag and drop your CSV file onto the Constant. ↳ Rulecube imports the CSV data into the constant table.
  3. Click Save.

Usage in code ​

If the Constant table you've dragged the CSV file on is named MyData, you may access it like this:

javascript
MyData.ccc.value2

This returns the value 10 from the example above.

To check if a key exists:

javascript
'bbb' in MyData

or

javascript
MyData.includes('bbb')