CSVReader Class Reference#

DiFfRG: DiFfRG::CSVReader Class Reference
DiFfRG
DiFfRG::CSVReader Class Reference

This class reads a .csv file and allows to access the data. More...

#include <csv_reader.hh>

Public Member Functions

 CSVReader (std::string input_file, char separator=',', bool has_header=false)
 Construct a new External Data Interpolator object.
 
size_t n_rows () const
 Get the number of rows in the .csv file.
 
size_t n_cols () const
 Get the number of columns in the .csv file.
 
double value (const std::string &col, const size_t row) const
 Get the stored value at a given row and column.
 
double value (const size_t col, const size_t row) const
 Get the stored value at a given row and column.
 

Private Attributes

std::string input_file
 
std::unique_ptr< rapidcsv::Document > document
 

Detailed Description

This class reads a .csv file and allows to access the data.

Constructor & Destructor Documentation

◆ CSVReader()

DiFfRG::CSVReader::CSVReader ( std::string input_file,
char separator = ',',
bool has_header = false )

Construct a new External Data Interpolator object.

Parameters
input_fileThe .csv file to read the data from.
separatorThe separator used in the .csv file.
has_headerWhether the .csv file has a header.

Member Function Documentation

◆ n_cols()

size_t DiFfRG::CSVReader::n_cols ( ) const

Get the number of columns in the .csv file.

Returns
uint The number of columns.

◆ n_rows()

size_t DiFfRG::CSVReader::n_rows ( ) const

Get the number of rows in the .csv file.

Returns
uint The number of rows.

◆ value() [1/2]

double DiFfRG::CSVReader::value ( const size_t col,
const size_t row ) const

Get the stored value at a given row and column.

Parameters
colThe column from which to get the value.
rowThe row from which to get the value.
Returns
double The data.

◆ value() [2/2]

double DiFfRG::CSVReader::value ( const std::string & col,
const size_t row ) const

Get the stored value at a given row and column.

Parameters
colThe name of the column from which to get the value.
rowThe row from which to get the value.
Returns
double The data.

Member Data Documentation

◆ document

std::unique_ptr<rapidcsv::Document> DiFfRG::CSVReader::document
private

◆ input_file

std::string DiFfRG::CSVReader::input_file
private

The documentation for this class was generated from the following file:
  • /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/common/csv_reader.hh