Jafar
|
Read a file containing comma separated values statements with or without first line as title. More...
Read a file containing comma separated values statements with or without first line as title.
Definition at line 21 of file csvFile.hpp.
#include <csvFile.hpp>
Public Member Functions | |
CSVFile (std::string const &separator_=" ", char commentPrefix_= '#', bool withColumnsNames_=false) | |
void | readFile (std::string const &filename) |
Parse file filename for comma separated values lines. | |
void | writeFile (std::string const &filename) |
Write file filename with comma separated values. | |
void | hasColumnsNames (const bool &_withColumnsNames) |
specify whether the first line is for column names or not. | |
bool | hasColumn (std::string const &columnName) const |
indicates whether this columnName exists | |
size_t | nbOfLines () const |
returns the number of lines loaded | |
size_t | nbOfColumns () const |
returns the number of columns per line | |
std::string | separator () const |
returns the values separator | |
char | commentPrefix () const |
returns the comment line prefix | |
template<class T > | |
void | getItem (size_t line, size_t columnNumber, T &value) const |
get the value at columnNumber at line. | |
template<class T > | |
void | getItem (size_t line, const std::string &columnName, T &value) const |
get the value of item columnName at line. | |
template<class T > | |
void | setItem (size_t line, size_t column, const T &value) |
set the value at column and line. | |
template<class T > | |
void | setItem (size_t line, const std::string &colName, const T &value) |
set the value of item column at line. | |
Private Types | |
typedef boost::numeric::ublas::matrix < std::string > | stringMatrix |
Static Private Member Functions | |
static void | compute_matrix_size (const std::string &_file, size_t &nb_lines, size_t &nb_columns, const std::string &_separator=" ", char _commentPrefix= '#') |
Private Attributes | |
std::string | m_separator |
columns separator, default to " ". | |
char | m_commentPrefix |
prefixes comment line | |
bool | withColumnsNames |
indicates if columns names are given | |
std::map< std::string, int > | columnNames |
map column name to an integer | |
stringMatrix | fileMatrix |
matrix used to save values | |
size_t | lineNumber |
size_t | dataLineNumber |
size_t | columnNumber |
void jafar::kernel::CSVFile::hasColumnsNames | ( | const bool & | _withColumnsNames | ) |
specify whether the first line is for column names or not.
It must use the same separator as the data.
void jafar::kernel::CSVFile::writeFile | ( | std::string const & | filename | ) |
Write file filename with comma separated values.
The current date is added in comment at the top of the file.
Generated on Wed Oct 15 2014 00:37:40 for Jafar by doxygen 1.7.6.1 |