DiFfRG
Loading...
Searching...
No Matches
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.
 
uint n_rows () const
 Get the number of rows in the .csv file.
 
uint n_cols () const
 Get the number of columns in the .csv file.
 
double value (const std::string &col, const uint row) const
 Get the stored value at a given row and column.
 
double value (const uint col, const uint 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()

uint DiFfRG::CSVReader::n_cols ( ) const

Get the number of columns in the .csv file.

Returns
uint The number of columns.

◆ n_rows()

uint 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 std::string & col,
const uint 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.

◆ value() [2/2]

double DiFfRG::CSVReader::value ( const uint col,
const uint 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.

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: