Read, store and retrieve data from a comma separated value file (csv)
More...
|
void | readFile (const std::string &filename, char delimiter) |
| Read data from a csv file and internally store it in a vector of string vectors. More...
|
|
std::vector< std::vector< std::string > > | getData () |
| Get data from csv file as a vector of string vectors. More...
|
|
std::vector< std::string > | getColumn (size_t column_number) |
| Get the contents of the column identified by column_number . More...
|
|
std::vector< std::string > | getRow (size_t row_number) |
| Get the contents of the row identified by row_number . More...
|
|
std::string | getElement (size_t column_number, size_t row_number) |
| Get the content of a cell, identified by column_number and row_number . More...
|
|
|
void | splitIntoSubstring (const std::string &data_string, const std::vector< char > &vector_split_point, std::vector< std::string > &vector_with_substrings) |
| Split data from one line into vector elements according to the separator. More...
|
|
|
std::vector< std::vector< std::string > > | _data_matrix |
|
Read, store and retrieve data from a comma separated value file (csv)
Definition at line 26 of file csv_reader.h.
◆ getColumn()
std::vector<std::string> getColumn |
( |
size_t |
column_number | ) |
|
Get the contents of the column identified by column_number
.
- Parameters
-
[in] | column_number | Number of the column, first column being 0 |
- Returns
- Data of the entire column.
◆ getData()
std::vector<std::vector<std::string> > getData |
( |
| ) |
|
Get data from csv file as a vector of string vectors.
- Returns
- The data, organized in a 2 dimensional vector (first index is the row, second index the column)
◆ getElement()
std::string getElement |
( |
size_t |
column_number, |
|
|
size_t |
row_number |
|
) |
| |
Get the content of a cell, identified by column_number
and row_number
.
- Parameters
-
[in] | column_number | Number of the column, first column being 0 |
[in] | row_number | Number of the row, first row being 0 |
- Returns
- Content of the specified cell
◆ getRow()
std::vector<std::string> getRow |
( |
size_t |
row_number | ) |
|
Get the contents of the row identified by row_number
.
- Parameters
-
[in] | row_number | Number of the row, first row being 0 |
- Returns
- Data of the entire row
◆ readFile()
void readFile |
( |
const std::string & |
filename, |
|
|
char |
delimiter |
|
) |
| |
Read data from a csv file and internally store it in a vector of string vectors.
- Parameters
-
[in] | filename | Full path to the file |
[in] | delimiter | The delimiter separating the data cells (';' or ',' and '
') |
◆ splitIntoSubstring()
void splitIntoSubstring |
( |
const std::string & |
data_string, |
|
|
const std::vector< char > & |
vector_split_point, |
|
|
std::vector< std::string > & |
vector_with_substrings |
|
) |
| |
|
private |
Split data from one line into vector elements according to the separator.
- Parameters
-
[in] | data_string | Reference to the string to be separated |
[in] | vector_split_point | Reference to a vector of strings with the separators of data, (';' or ',') and line separator '
' |
[in] | vector_with_substrings | Reference to a vector of strings with the data separated as vector elements |