Skip to content

Commit 05fb80b

Browse files
committedJan 10, 2013
Added forgotten CsvProcessor.h
1 parent 79048af commit 05fb80b

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
 

‎CsvProcessor.h

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#ifndef CSVPROCESSOR_h
2+
#define CSVPROCESSOR_h
3+
4+
#include <vector>
5+
#include <string>
6+
#include <fstream>
7+
#include <set>
8+
#include <vector>
9+
#include "Hash.h"
10+
//#include <boost/function.hpp>
11+
//#include <exception>
12+
13+
using namespace std;
14+
15+
struct Exception {
16+
string errorString;
17+
Exception (const string &_errorString): errorString(_errorString){}
18+
};
19+
20+
class CsvProcessor {
21+
22+
private:
23+
//boost::function <void(string)> hashFunc;
24+
Hash &hash;
25+
ifstream inFile;
26+
ofstream outFile;
27+
string inFileName;
28+
string outFileName;
29+
vector <string> columnNames;
30+
set <size_t> scrambledCols;
31+
size_t numCols;
32+
char delim;
33+
string delims;
34+
bool hasHeader;
35+
void splitLine(const string &line, vector <string> &tokens);
36+
void readHeaders();
37+
size_t getNumCols(); // returns num cols and moves file pointer back to original position
38+
/*
39+
inline void CsvParser::splitLine(const string &line, vector <string> &tokens) {
40+
boost::split(tokens, query, boost::is_any_of(delims));
41+
}
42+
*/
43+
44+
public:
45+
CsvProcessor (const string &_inFileName, const string &_outFileName, const char _delim, bool _hasHeader, Hash &_hash);
46+
~CsvProcessor();
47+
void setScrambledColumnNames(const vector <string> &scrambledColumnNames);
48+
void setScrambledColumnNums(const vector<size_t> &scrambledColumnNums);
49+
void writeOutput();
50+
};
51+
52+
#endif
53+
54+

‎README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CsvProcessor takes a csv file as input and hashes specified fields, writing the
2+
output to a new csv file.

0 commit comments

Comments
 (0)