Simpact Cyan
Population based event driven simulation using mNRM
|
This is a helper class for reading CSV files, which are assumed to hold numbers. More...
#include <csvfile.h>
Public Member Functions | |
bool_t | load (const std::string &fileName) |
Try to load the specified file, setting the error string if failed. More... | |
int | getNumberOfColumns () |
Returns the number of columns in the loaded file. More... | |
int | getNumberOfRows () |
Returns the number of rows in the loaded file. More... | |
bool | hasValue (int row, int column) |
Returns true if a numerical value exists for the specified position. More... | |
double | getValue (int row, int column) |
Returns the stored value for the specified position. More... | |
const std::string | getColumnName (int col) const |
Returns the name of the specified column (from the header). More... | |
This is a helper class for reading CSV files, which are assumed to hold numbers.
If the entries of the first line contain " characters (double quotes), the first line is assumed to consist of headers, for example:
"X", "Y" 0.1, 2.3 0.2, 4.5 0.3, 6.6
If an entry of the first line can not be interpreted as a numerical value, the line is also considered to be header values, for example:
0, Y 0.1, 2.3 0.2, 4.5 0.3, 6.6
If the first line does not contain double quotes and all entries are numerical values, the CSV file is assumed to not have a header, only containing data.
const std::string CSVFile::getColumnName | ( | int | col | ) | const |
Returns the name of the specified column (from the header).
int CSVFile::getNumberOfColumns | ( | ) |
Returns the number of columns in the loaded file.
int CSVFile::getNumberOfRows | ( | ) |
Returns the number of rows in the loaded file.
double CSVFile::getValue | ( | int | row, |
int | column | ||
) |
Returns the stored value for the specified position.
bool CSVFile::hasValue | ( | int | row, |
int | column | ||
) |
Returns true if a numerical value exists for the specified position.
bool_t CSVFile::load | ( | const std::string & | fileName | ) |
Try to load the specified file, setting the error string if failed.