-
Notifications
You must be signed in to change notification settings - Fork 1
/
CSVReader.h
34 lines (28 loc) · 1 KB
/
CSVReader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef _CSV_READER_H_
#define _CSV_READER_H_
#include <istream>
#include <sstream>
#include <cstring>
#include <dirent.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
#include "Table.h"
class CSVReader {
private:
char field_delimiter = ','; // '\t'
int filesize(const char* filename);
bool ends_with(std::string const & value, std::string const & ending);
void csv_read_row(std::istream &in, std::vector<std::string> &row, bool isNorm = true);
bool get_table(const string &filepath, vector<string> &headers, vector<unordered_map<string, int>> &columns, vector<vector<string>> &rows, bool normalize);
int max_val_len;
public:
CSVReader() {}
vector<Table> tables;
void strNormalize(string &s); // also for the use of query normalization
bool reading(string &datafilespath, bool normalize);
void write_one_table(const Table &table, const string &outfilename);
bool reading_one_table(string &datafilepath, bool normalize);
int get_max_val_len() { return max_val_len; };
};
#endif