|
| CSVReader (std::string filename, std::string delm=",") |
|
std::vector< std::vector< std::string > > | getData () |
| Reads and parses data from a CSV, ASCII or TIFF file into a 2D vector.
|
|
void | printData (std::vector< std::vector< std::string > > &DF) |
| print data contained in 2D vector to console row by row
|
|
void | parseDF (inputs *df_ptr, std::vector< std::vector< std::string > > &DF, arguments *args_ptr, int NCells) |
| Populates an instance of inputs using information contained in a 2D vector.
|
|
void | parseNDF (std::vector< int > &NFTypes, std::vector< std::vector< std::string > > &DF, int NCells) |
| Populates a vector of size NCells with fuel type number per cell.
|
|
void | parsePROB (std::vector< float > &probabilities, std::vector< std::vector< std::string > > &DF, int NCells) |
| Not currently supported. Populates a vector of size NCells with ignition probability per cell.
|
|
void | parseWeatherDF (weatherDF *wt_ptr, arguments *args_ptr, std::vector< std::vector< std::string > > &DF, int WPeriods) |
|
void | parseIgnitionDF (std::vector< int > &ig, std::vector< std::vector< std::string > > &DF, int IgPeriods) |
|
void | parseForestDF (forestDF *frt_ptr, std::vector< std::vector< std::string > > &DF) |
|
void | parseHarvestedDF (std::unordered_map< int, std::vector< int > > &hc, std::vector< std::vector< std::string > > &DF, int HPeriods) |
|
void | parseBBODF (std::unordered_map< int, std::vector< float > > &bbo, std::vector< std::vector< std::string > > &DF, int NFTypes) |
|
void | printDF (inputs df) |
|
void | printWeatherDF (weatherDF wdf) |
|
std::vector< std::vector< std::string > > CSVReader::getData |
( |
| ) |
|
Reads and parses data from a CSV, ASCII or TIFF file into a 2D vector.
Checks for the existence of the input file with either a .tif
or .asc
extension and processes it accordingly. If the file is in CSV format, it is read line by line and split using the specified delimiter. If the file is in ASCII format, the function reads the header separately before parsing the data. If the file is in TIFF format, it extracts metadata (e.g., grid dimensions, cell size, and coordinates) and reads raster data row by row.
- Returns
- A 2D vector of strings containing the parsed data.
- For ASC and CSV files, each row is stored as a vector of strings.
- For TIFF files, metadata is stored in the first few rows, followed by pixel values.
- Exceptions
-
std::runtime_error | If the file type is unsupported, memory allocation fails, or an error occurs during file reading. |