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