-
Notifications
You must be signed in to change notification settings - Fork 0
/
CsvProcessor.h
54 lines (45 loc) · 1.45 KB
/
CsvProcessor.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef CSVPROCESSOR_h
#define CSVPROCESSOR_h
#include <vector>
#include <string>
#include <fstream>
#include <set>
#include <vector>
#include "Hash.h"
//#include <boost/function.hpp>
//#include <exception>
using namespace std;
struct Exception {
string errorString;
Exception (const string &_errorString): errorString(_errorString){}
};
class CsvProcessor {
private:
//boost::function <void(string)> hashFunc;
Hash &hash;
ifstream inFile;
ofstream outFile;
string inFileName;
string outFileName;
vector <string> columnNames;
set <size_t> scrambledCols;
size_t numCols;
char delim;
string delims;
bool hasHeader;
void splitLine(const string &line, vector <string> &tokens);
void readHeaders();
size_t getNumCols(); // returns num cols and moves file pointer back to original position
/*
inline void CsvParser::splitLine(const string &line, vector <string> &tokens) {
boost::split(tokens, query, boost::is_any_of(delims));
}
*/
public:
CsvProcessor (const string &_inFileName, const string &_outFileName, const char _delim, bool _hasHeader, Hash &_hash);
~CsvProcessor();
void setScrambledColumnNames(const vector <string> &scrambledColumnNames);
void setScrambledColumnNums(const vector<size_t> &scrambledColumnNums);
void writeOutput();
};
#endif