#include <CSVFile.hpp>
Public Member Functions | |
unsigned | addColumn (const std::vector< DateTime > &dateTimes) |
Add a column of std::vector<DateTime>, returns column index (first column is index 0). More... | |
unsigned | addColumn (const Vector &values) |
Add a column of values in a Vector, returns column index (first column is index 0). More... | |
unsigned | addColumn (const std::vector< double > &values) |
Add a column of values in a std::vector<double>, returns column index (first column is index 0). More... | |
unsigned | addColumn (const std::vector< std::string > &values) |
Add a column of values in a std::vector<std::string>, returns column index (first column is index 0). More... | |
void | addRow (const std::vector< Variant > &row) |
Add a row. More... | |
void | clear () |
Clear all rows. More... | |
CSVFile | clone () const |
Clones this CSVFile into a separate one. More... | |
CSVFile () | |
Create a new, empty CSVFile. More... | |
CSVFile (const std::string &s) | |
Constructor with string, will throw if string is not a CSVFile. More... | |
CSVFile (const openstudio::path &p) | |
Constructor with path, will throw if path does not exist or file is incorrect. More... | |
std::vector< DateTime > | getColumnAsDateTimes (unsigned columnIndex) const |
Get column of DateTime values (first column is index 0). More... | |
std::vector< double > | getColumnAsDoubleVector (unsigned columnIndex) const |
Get column as a Vector (first column is index 0). More... | |
std::vector< std::string > | getColumnAsStringVector (unsigned columnIndex) const |
Get column as a Vector (first column is index 0). More... | |
unsigned | numColumns () const |
Returns number of columns, this is the maximum number of columns across all rows. More... | |
unsigned | numRows () const |
Returns number of rows. More... | |
boost::optional< openstudio::path > | path () const |
Returns the absolute path this CSVFile was loaded from or saved to, empty for new CSVFile. More... | |
void | resetPath () |
Resets the absolute path for this CSVFile. More... | |
std::vector< std::vector < Variant > > | rows () const |
Get all rows. More... | |
bool | save () const |
Saves this file to the current location, fails if no path is set. More... | |
bool | saveAs (const openstudio::path &p) |
Saves this file to a new location. More... | |
bool | setPath (const openstudio::path &path) |
Sets the absolute path for this CSVFile. More... | |
void | setRows (const std::vector< std::vector< Variant > > &rows) |
Set all rows. More... | |
std::string | string () const |
Get the CSVFile as a string. More... | |
Static Public Member Functions | |
static boost::optional< CSVFile > | load (const std::string &s) |
Attempt to load a CSVFile from string. More... | |
static boost::optional< CSVFile > | load (const openstudio::path &p) |
Attempt to load a CSVFile from path. More... | |
Protected Member Functions | |
CSVFile (std::shared_ptr< detail::CSVFile_Impl > impl) | |
Protected constructor from impl. More... | |
Class for reading and writing CSV files.
openstudio::CSVFile::CSVFile | ( | ) |
Create a new, empty CSVFile.
openstudio::CSVFile::CSVFile | ( | const std::string & | s | ) |
Constructor with string, will throw if string is not a CSVFile.
openstudio::CSVFile::CSVFile | ( | const openstudio::path & | p | ) |
Constructor with path, will throw if path does not exist or file is incorrect.
|
protected |
Protected constructor from impl.
unsigned openstudio::CSVFile::addColumn | ( | const std::vector< DateTime > & | dateTimes | ) |
Add a column of std::vector<DateTime>, returns column index (first column is index 0).
unsigned openstudio::CSVFile::addColumn | ( | const Vector & | values | ) |
Add a column of values in a Vector, returns column index (first column is index 0).
unsigned openstudio::CSVFile::addColumn | ( | const std::vector< double > & | values | ) |
Add a column of values in a std::vector<double>, returns column index (first column is index 0).
unsigned openstudio::CSVFile::addColumn | ( | const std::vector< std::string > & | values | ) |
Add a column of values in a std::vector<std::string>, returns column index (first column is index 0).
void openstudio::CSVFile::addRow | ( | const std::vector< Variant > & | row | ) |
Add a row.
void openstudio::CSVFile::clear | ( | ) |
Clear all rows.
std::vector<DateTime> openstudio::CSVFile::getColumnAsDateTimes | ( | unsigned | columnIndex | ) | const |
std::vector<double> openstudio::CSVFile::getColumnAsDoubleVector | ( | unsigned | columnIndex | ) | const |
Get column as a Vector (first column is index 0).
Empty vector is returned if any cell is not a valid number or if column index is invalid.
std::vector<std::string> openstudio::CSVFile::getColumnAsStringVector | ( | unsigned | columnIndex | ) | const |
Get column as a Vector (first column is index 0).
Numeric cells will be converted to strings. Empty vector is returned if column index is invalid.
|
static |
Attempt to load a CSVFile from string.
|
static |
Attempt to load a CSVFile from path.
unsigned openstudio::CSVFile::numColumns | ( | ) | const |
Returns number of columns, this is the maximum number of columns across all rows.
unsigned openstudio::CSVFile::numRows | ( | ) | const |
Returns number of rows.
boost::optional<openstudio::path> openstudio::CSVFile::path | ( | ) | const |
void openstudio::CSVFile::resetPath | ( | ) |
Resets the absolute path for this CSVFile.
std::vector<std::vector<Variant> > openstudio::CSVFile::rows | ( | ) | const |
Get all rows.
bool openstudio::CSVFile::save | ( | ) | const |
Saves this file to the current location, fails if no path is set.
bool openstudio::CSVFile::saveAs | ( | const openstudio::path & | p | ) |
Saves this file to a new location.
Updates the CSVFile path.
bool openstudio::CSVFile::setPath | ( | const openstudio::path & | path | ) |
Sets the absolute path for this CSVFile.
void openstudio::CSVFile::setRows | ( | const std::vector< std::vector< Variant > > & | rows | ) |
Set all rows.
std::string openstudio::CSVFile::string | ( | ) | const |
Get the CSVFile as a string.