Dynamic Dataset(s) Accessing
How to Create a file for multiple datafiles execution
The order datasets are added when a new experiment is created is the order of the IDs in RAISE_DATASET_ID_LIST.
In the following experiment the first dataset is the “RAISE Consortium questionnaire (second…)” and the second dataset is the “Iris”.
The id of the first dataset is in the first element of the list, the second dataset id is stored in the second element, and so on. Load dataset UUIDs in that order to avoid reading the wrong file.
In RAISE this list is filled in for you from the experiment’s dataset order.
When you debug locally, create a .env file in the experiment root with RAISE_DATASET_ID_LIST and place each sample under {datasetId}/datafile.{ext}.
RAISE_DATASET_ID_LIST=["00000000-0000-0000-0000-000000000001","00000000-0000-0000-0000-000000000002"]To reuse the same script on similar files, create the new experiment with datasets in the same order and with the same file types. For a streamed dataset, the snapshot file is still named datafile in that folder.
Python
import jsonfrom dotenv import load_dotenv
load_dotenv()dataset_ids = json.loads(os.getenv("RAISE_DATASET_ID_LIST"))xls = pd.ExcelFile(f"{dataset_ids[0]}/datafile.xlsx", engine = 'openpyxl')NodeJS
import dotenv from 'dotenv';dotenv.config(); // safe to call even if .env (local environment variables) doesn't exist
const datasetIds = JSON.parse(process.env.RAISE_DATASET_ID_LIST || "[]");
if (!Array.isArray(datasetIds) || datasetIds.length === 0) { console.error("RAISE_DATASET_ID_LIST is missing or empty."); process.exit(1);}
const csvFilePath = `${datasetIds[0]}/datafile.csv`;R
library(dotenv)library(jsonlite)
# --- Load environment locally ---if (file.exists(".env")) load_dot_env(file = ".env")
# --- Load dataset ID list ---dataset_env <- Sys.getenv("RAISE_DATASET_ID_LIST")if (dataset_env == "") { stop("Environment variable RAISE_DATASET_ID_LIST is missing.")}
dataset_ids <- fromJSON(dataset_env)if (length(dataset_ids) == 0) { stop("RAISE_DATASET_ID_LIST is empty or invalid JSON.")}
# Access the filecsv_file_path <- file.path(dataset_ids[[1]], "datafile.csv")For a full walkthrough see Python script.