ADTF  3.18.3
csv_reader.h
Go to the documentation of this file.
1 
15 #ifndef A_UTILS_UTIL_CSV_READER_HEADER_INCLUDED_
16 #define A_UTILS_UTIL_CSV_READER_HEADER_INCLUDED_
17 
18 #include <string>
19 #include <vector>
20 
21 namespace a_util {
22 namespace parser {
26 class CSVReader {
27 private:
28  std::vector<std::vector<std::string>> _data_matrix;
29 
30 public:
36  void readFile(const std::string& filename, char delimiter);
37 
43  std::vector<std::vector<std::string>> getData();
44 
50  std::vector<std::string> getColumn(size_t column_number);
51 
57  std::vector<std::string> getRow(size_t row_number);
58 
65  std::string getElement(size_t column_number, size_t row_number);
66 
67 private:
76  void splitIntoSubstring(const std::string& data_string,
77  const std::vector<char>& vector_split_point,
78  std::vector<std::string>& vector_with_substrings);
79 };
80 
81 } // namespace parser
82 } // namespace a_util
83 
84 #endif // A_UTILS_UTIL_CSV_READER_HEADER_INCLUDED_
Read, store and retrieve data from a comma separated value file (csv)
Definition: csv_reader.h:26
std::vector< std::string > getColumn(size_t column_number)
Get the contents of the column identified by column_number.
std::string getElement(size_t column_number, size_t row_number)
Get the content of a cell, identified by column_number and row_number.
void splitIntoSubstring(const std::string &data_string, const std::vector< char > &vector_split_point, std::vector< std::string > &vector_with_substrings)
Split data from one line into vector elements according to the separator.
void readFile(const std::string &filename, char delimiter)
Read data from a csv file and internally store it in a vector of string vectors.
std::vector< std::string > getRow(size_t row_number)
Get the contents of the row identified by row_number.
std::vector< std::vector< std::string > > getData()
Get data from csv file as a vector of string vectors.
Serves as the root component, with common functionality documented in core functionality.
Definition: base.h:24