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

Referencing Data in Expressions

Once imported, you can reference any column using the data.* namespace in dynamic expressions. Kalix provides two ways to reference columns:

By Column Name

data.<filename>.by_name.<column_name>

By Column Index

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:

Name Sanitisation

Kalix sanitises filenames and column names to ensure valid references:

  1. Lowercase conversion - all names become lowercase
  2. Special character replacement - characters other than 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.

Temporal Offset Syntax

You can access values from previous or future timesteps using offset syntax: