read_list_table¶
Syntax¶
Parameters¶
list_table_name- The list-table to update
filename- The name of comma-separated file. The file-name may include the path to the file.
key_col- The index of the column containing keys (starting from 0)
val_col- The index of the column containing values
Description¶
Populates a list-table with key-value pairs from a CSV file.
Updates a provided list-table with a series of key-value pairs from the specified filename. The file must be a comma-separated-value file that contains the indicated columns. For each key-value pair read from the file, the value is updated or appended to the list associated with the key in list_table.
Empty lines in the file are ignored.
Lines with a non-numeric value in the first column are ignored.
The value associated with any key that appears in the key_col is replaced by the list of values for that key in the file. Other keys are not affected.
An error occurs if the file is not found, or if the column indices do not exist.
Examples¶
population.csv
variables {
shared table my_list_table
}
condition LOADING {
meta_start_state = Start
state Start {
# populate table with key and value from .csv file
read_table(my_list_table, population.csv, 0, 1)
wait()
default()
}
}