On this page:
read_  csv
read_  csv_  headers
read_  csv_  data
8.18

9 The csv library🔗ℹ

This library provides a function for reading comma-separated values (CSV) files.

procedure

read_csv(input: str?): VecC[VecC[str?]]

Reads the CSV file input and returns its contents as a vector of vectors of strings. The outer vector has one element for each row in the file, and each row has one element for each column in the row. Individual cells are represented as strings.

For example, a CSV file containing the following:

state,initial,capital

Illinois,IL,Springfield

Massachusetts,MA,Boston

Missouri,MO,Jefferson City

would be read into:

[['state', 'initial', 'capital'],
 ['Illinois', 'IL', 'Springfield'],
 ['Massachusetts', 'MA', 'Boston'],
 ['Missouri', 'MO', 'Jefferson City']]

procedure

read_csv_headers(input: str?): VecC[str?]

Reads the CSV file input and returns the contents of its first row, which are assumed to be column headers.

procedure

read_csv_data(input: str?): VecC[VecC[str?]]

Reads the CSV file input and returns the contents of its second and later rows, skipping the first (which is assumed to contain column headers).