Skip to content

read_list_table

Syntax

read_list_table(list_table_name, filename, key_col, val_col)

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)
key_val
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

# Populates the county_pop_size table using tabulated values from county-pops.csv 
read_table(county_pop_size, county-pops.csv, 0, 1)

See Also