\(\newcommand{\B}[1]{ {\bf #1} }\) \(\newcommand{\R}[1]{ {\rm #1} }\)
csv_read¶
View page sourceRead a Csv File¶
Prototype¶
vec_vec_str csv_read(const std::string& file_name)
// ...
return csv_table;
vec_vec_str¶
see vec_vec_str .
file_name¶
is the name of the file containing the csv file.
Each row in this file ends with a newlines '\n'.
The columns are separated by commas ',' .
A comma at the end of a line means there is an empty value
at the end of the corresponding row.
There are no other special characters in this file.
csv_table¶
The j-th column of the i-th row of the file contains the value csv_table[i][j] . The special characters
'\n'and','are not included in these values.The row and column indices start at zero.
csv_table.size() is the number of rows in the table
csv_table[i].size() is the number of columns in the i-th row.
Example¶
xam_csv_read.cpp contains an example and test of this routine.