This class is responsible for handling and storing iCSV files.
General information about the file is stored as public members, the station_location is an additional member. The MetaData is stored in the METADATA member, and the fields are stored in the FIELDS member.
It is possible to store all the data as well with read_sequential= false
Format checking is done on initialization.
Getters are provided to access the data, Metadata is directly accessed.
#include <iCSVHelper.h>
Public Member Functions | |
iCSVFile () | |
iCSVFile (const iCSVFile &) | |
iCSVFile (const std::string &infile, const bool &read_sequential) | |
Reads a iCSV file, and checks the format. More... | |
void | readFile (const std::string &infile, const bool &sequentially) |
bool | checkFormatValidity () |
Checks the validity of the format for the iCSVFile. More... | |
bool | checkMeteoIOCompatibility () const |
void | parseGeometry () |
Parses the geometry information of the iCSV file. More... | |
double | getNoData () const |
double | getTimeZone () const |
const std::vector< std::vector< double > > & | getRowData () const |
const std::vector< Date > & | getAllDatesInFile () const |
const std::vector< geoLocation > & | getAllLocationsInData () const |
geoLocation | getLocationAt (size_t index) const |
std::vector< Date > | getDatesInFile (const Date &start_date, const Date &end_date) const |
std::vector< geoLocation > | getLocationsInData (const Date &start_date, const Date &end_date) const |
bool | processLine (const std::string &line, std::string §ion, const bool &sequentially) |
void | processContent (const std::string &content, const std::string §ion) |
void | processData (const std::string &content) |
bool | isValidLocation (const geoLocation &location) |
bool | isColumnName (const std::string &geometry) |
void | findTime () |
void | findLocation () |
std::vector< std::string > | columnsToAppend (const std::vector< MeteoData > &vecMeteo) const |
double | readData (const Date &r_date, const std::string &fieldname) |
void | aggregateData (const std::vector< MeteoData > &vecMeteo) |
void | populateMetaData (const std::string &key, const std::string &value) |
void | populateFields (const std::string &key, const std::string &value) |
Public Attributes | |
size_t | skip_lines_to_data |
std::string | filename |
std::string | firstline |
geoLocation | station_location |
MetaDataSection | METADATA |
fieldsSection | FIELDS |
bool | location_in_header = true |
bool | timezone_in_data = false |
bool | timestamp_present = false |
bool | julian_present = false |
size_t | time_id = IOUtils::npos |
size_t | location_id = IOUtils::npos |
mio::iCSV::iCSVFile::iCSVFile | ( | ) |
mio::iCSV::iCSVFile::iCSVFile | ( | const iCSVFile & | other | ) |
mio::iCSV::iCSVFile::iCSVFile | ( | const std::string & | infile, |
const bool & | read_sequential | ||
) |
void mio::iCSV::iCSVFile::aggregateData | ( | const std::vector< MeteoData > & | vecMeteo | ) |
Aggregates data from the given vector of MeteoData objects.
[in] | vecMeteo | The vector of MeteoData objects to aggregate. |
IOException | if the vector is empty. |
bool mio::iCSV::iCSVFile::checkFormatValidity | ( | ) |
Checks the validity of the format for the iCSVFile.
bool mio::iCSV::iCSVFile::checkMeteoIOCompatibility | ( | ) | const |
std::vector< std::string > mio::iCSV::iCSVFile::columnsToAppend | ( | const std::vector< MeteoData > & | vecMeteo | ) | const |
Finds parameters, that are used in MeteoIO but not given in a iCSV file.
[in] | vecMeteo | The vector of MeteoData objects to compare with. |
IOException | if the vector is empty. |
void mio::iCSV::iCSVFile::findLocation | ( | ) |
void mio::iCSV::iCSVFile::findTime | ( | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
bool mio::iCSV::iCSVFile::isColumnName | ( | const std::string & | geometry | ) |
bool mio::iCSV::iCSVFile::isValidLocation | ( | const geoLocation & | location | ) |
void mio::iCSV::iCSVFile::parseGeometry | ( | ) |
Parses the geometry information of the iCSV file.
This function extracts the coordinates from the metadata and checks if they are valid. If the coordinates are empty or not a known WKTS station location, an exception is thrown. If the z-coordinate is set to the default nodata value, it is updated to the actual nodata value. Finally, the station location is updated with the parsed coordinates.
IOException | if the geometry is neither a column name nor a known WKTS station location, or if the location is invalid. |
void mio::iCSV::iCSVFile::populateFields | ( | const std::string & | key, |
const std::string & | value | ||
) |
void mio::iCSV::iCSVFile::populateMetaData | ( | const std::string & | key, |
const std::string & | value | ||
) |
void mio::iCSV::iCSVFile::processContent | ( | const std::string & | content, |
const std::string & | section | ||
) |
void mio::iCSV::iCSVFile::processData | ( | const std::string & | content | ) |
bool mio::iCSV::iCSVFile::processLine | ( | const std::string & | line, |
std::string & | section, | ||
const bool & | sequentially | ||
) |
double mio::iCSV::iCSVFile::readData | ( | const Date & | r_date, |
const std::string & | fieldname | ||
) |
Reads the data for a given date and fieldname from the iCSV file.
[in] | r_date | The date for which to read the data. |
[in] | fieldname | The name of the field for which to read the data. |
IOException | If there is no data available or if the date is out of range. |
void mio::iCSV::iCSVFile::readFile | ( | const std::string & | infile, |
const bool & | sequentially | ||
) |
Reads the contents of a iCSV file.
[in] | infile | The path of the input file to be read. |
[in] | sequentially | Flag indicating whether to read the data |
IOException | If there is an error opening or reading the file. |
InvalidFormatException | If the iCSV file format is invalid. |
fieldsSection mio::iCSV::iCSVFile::FIELDS |
std::string mio::iCSV::iCSVFile::filename |
std::string mio::iCSV::iCSVFile::firstline |
bool mio::iCSV::iCSVFile::julian_present = false |
size_t mio::iCSV::iCSVFile::location_id = IOUtils::npos |
bool mio::iCSV::iCSVFile::location_in_header = true |
MetaDataSection mio::iCSV::iCSVFile::METADATA |
size_t mio::iCSV::iCSVFile::skip_lines_to_data |
geoLocation mio::iCSV::iCSVFile::station_location |
size_t mio::iCSV::iCSVFile::time_id = IOUtils::npos |
bool mio::iCSV::iCSVFile::timestamp_present = false |
bool mio::iCSV::iCSVFile::timezone_in_data = false |