MoCSI API Reference
Loading...
Searching...
No Matches
CsvParser.h
Go to the documentation of this file.
1#ifndef CSV_PARSER_H
2#define CSV_PARSER_H
3
4#include <fstream>
5#include <string>
6#include <vector>
7
8#include "IniParser.h" // I just need the BadInput class, we should move them to a central "error" header
9
17{
18 private:
19 std::vector<std::vector<double>> m_file_content;
20 std::vector<std::string> m_snapshot_fields;
21 double m_snapshot_time{0.0};
22 bool m_allow_missing_values{false};
23 bool m_is_snapshot_file{false};
24 char m_delimiter;
25
26 void parseFile(const std::string& filename);
27 void writeVector(std::vector<double>& vector, std::string& current_value,
28 bool allow_missing_value) const;
29 void checkSnapshotTime(const std::string& time);
30
31 public:
32 // void _parse_file(const std::string& filename);
33 CsvParser(const std::string& filename, char delimiter = ',');
34 CsvParser(const std::string& filename, const std::string& filetype, char delimiter = ',');
35 CsvParser(const std::string& filename, bool allow_missing_values, char delimiter = ',');
36 CsvParser(const std::string& filename, const std::string& filetype,
37 bool allow_missing_values, char delimiter = ',');
38
39 const std::vector<std::vector<double>>& getCsvContents() const { return m_file_content; }
40
41 void getSnapshotContents(std::vector<std::vector<double>>& field_values,
42 std::vector<std::string>& key_list, double& elapsed_time)
43 {
44 field_values = m_file_content;
45 key_list = m_snapshot_fields;
46 elapsed_time = m_snapshot_time;
47 }
48
49 std::string trim(const std::string& str);
50};
51
52#endif
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix....
Definition CsrMatrix.h:35
This class parses csv files. Parses the files as a vector of vectors of type double where each row in...
Definition CsvParser.h:17
const std::vector< std::vector< double > > & getCsvContents() const
Definition CsvParser.h:39
std::string trim(const std::string &str)
void getSnapshotContents(std::vector< std::vector< double > > &field_values, std::vector< std::string > &key_list, double &elapsed_time)
Definition CsvParser.h:41