The page Declaring Input Data explains how to import data in your Kalix model. Here’s a reminder:
[inputs]
./data/climate.csv
./data/streamflow.csv
Each CSV file should have a date/timestamp column as the first column, followed by one or more data columns:
Date,Rainfall,Evaporation
2020-01-01,12.5,4.2
2020-01-02,0.0,5.1
Once imported, you can reference any column using the data.* namespace in dynamic expressions. Kalix provides two ways to reference columns:
data.<filename>.by_name.<column_name>
data.<filename>.by_index.<column_number>
Column indices start at 1 (the first data column after the date column).
Example: For climate.csv with columns Date, Rainfall, Evaporation:
data.climate_csv.by_name.rainfall - references the Rainfall columndata.climate_csv.by_index.1 - also references the Rainfall columndata.climate_csv.by_index.2 - references the Evaporation columnKalix sanitises filenames and column names to ensure valid references:
a-z, 0-9, and _ are replaced with underscores| Original | Sanitised |
|---|---|
Climate-Data.csv |
climate_data_csv |
Flow (ML/d) |
flow__ml_d_ |
Station_001 |
station_001 |
This means references are case-insensitive - data.climate_csv.by_name.Rainfall and data.climate_csv.by_name.rainfall both work.
You can access values from previous or future timesteps using offset syntax: