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 | 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... | |
Public Member Functions inherited from errut::ErrorBase | |
ErrorBase () | |
Creates an instance without an explicit object name. More... | |
ErrorBase (const std::string &objName) | |
Creates an instance with the object name set to objName . More... | |
std::string | getObjectName () const |
Returns the stored object name. More... | |
std::string | getErrorString () const |
Returns the currently stored error message. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from errut::ErrorBase | |
void | setErrorString (const std::string &str) const |
Derived classes can use this member function to store an error message. 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 CSVFile::load | ( | const std::string & | fileName | ) |
Try to load the specified file, setting the error string if failed.