MoCSI API Reference
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CsvParser Class Reference

This class parses csv files. Parses the files as a vector of vectors of type double where each row in the file is one vector. It parses ONLY the values and not any text or comments within the file. More...

#include <CsvParser.h>

Collaboration diagram for CsvParser:
Collaboration graph

Public Member Functions

 CsvParser (const std::string &filename, char delimiter=',')
 Constructor for the CsvParser class. Parses an csv file into a std::vector<std::vector<double>>.
 
 CsvParser (const std::string &filename, const std::string &filetype, char delimiter=',')
 Constructor for the CsvParser class. Parses an csv file into a std::vector<std::vector<double>>. Allows to specify the filetype, currently only option is snapshot or default.
 
 CsvParser (const std::string &filename, bool allow_missing_values, char delimiter=',')
 Constructor for the CsvParser class. Parses an csv file into a std::vector<std::vector<double>>. Allows to specify how to proceed with missing values.
 
 CsvParser (const std::string &filename, const std::string &filetype, bool allow_missing_values, char delimiter=',')
 Constructor for the CsvParser class. Parses an csv file into a std::vector<std::vector<double>>. Allows to specify how to proceed with missing values. Allows to specify the filetype, currently only option is snapshot or default.
 
const std::vector< std::vector< double > > & getCsvContents () const
 
void getSnapshotContents (std::vector< std::vector< double > > &field_values, std::vector< std::string > &key_list, double &elapsed_time)
 
std::string trim (const std::string &str)
 

Detailed Description

This class parses csv files. Parses the files as a vector of vectors of type double where each row in the file is one vector. It parses ONLY the values and not any text or comments within the file.

Constructor & Destructor Documentation

◆ CsvParser() [1/4]

CsvParser::CsvParser ( const std::string &  filename,
char  delimiter = ',' 
)

Constructor for the CsvParser class. Parses an csv file into a std::vector<std::vector<double>>.

Parameters
filenameThe file path.

◆ CsvParser() [2/4]

CsvParser::CsvParser ( const std::string &  filename,
const std::string &  filetype,
char  delimiter = ',' 
)

Constructor for the CsvParser class. Parses an csv file into a std::vector<std::vector<double>>. Allows to specify the filetype, currently only option is snapshot or default.

Parameters
filenameThe file path.

◆ CsvParser() [3/4]

CsvParser::CsvParser ( const std::string &  filename,
bool  allow_missing_values,
char  delimiter = ',' 
)

Constructor for the CsvParser class. Parses an csv file into a std::vector<std::vector<double>>. Allows to specify how to proceed with missing values.

Parameters
filenameThe file path.
allow_missing_valuesIf true, parses all empty values in the file a NAN.

◆ CsvParser() [4/4]

CsvParser::CsvParser ( const std::string &  filename,
const std::string &  filetype,
bool  allow_missing_values,
char  delimiter = ',' 
)

Constructor for the CsvParser class. Parses an csv file into a std::vector<std::vector<double>>. Allows to specify how to proceed with missing values. Allows to specify the filetype, currently only option is snapshot or default.

Parameters
filenameThe file path.
allow_missing_valuesIf true, parses all empty values in the file a NAN.

Member Function Documentation

◆ getCsvContents()

const std::vector< std::vector< double > > & CsvParser::getCsvContents ( ) const
inline

◆ getSnapshotContents()

void CsvParser::getSnapshotContents ( std::vector< std::vector< double > > &  field_values,
std::vector< std::string > &  key_list,
double elapsed_time 
)
inline

◆ trim()

std::string CsvParser::trim ( const std::string &  str)

The documentation for this class was generated from the following files: