-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsvTest.cpp
More file actions
66 lines (57 loc) · 1.64 KB
/
csvTest.cpp
File metadata and controls
66 lines (57 loc) · 1.64 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "quicksorts-revised.hpp"
#include <iostream>
#include <algorithm>
#include <random>
#include <assert.h>
#include <fstream>
#include <chrono>
#include "csvLine.hpp"
using namespace std;
using namespace ExternalQuicksorts;
typedef chrono::high_resolution_clock Clock;
int main(int argc, char** argv){
string readName(argv[1]);
string outName(argv[2]);
vector<int> colOrder;
vector<bool> isInt;
istringstream colLine(argv[3]);
string colWd;
while( getline(colLine, colWd, ',')){
colOrder.push_back(stoi(colWd));
}
CsvWrapper::setColOrder(colOrder);
int threads = stoi(argv[4]);
auto startClock = Clock::now();
ifstream readFile;
ofstream outFile;
readFile.open(readName);
outFile.open(outName);
int fileLength = 0;
string line;
if(readFile >> line){
++fileLength;
outFile << line << endl;
istringstream fmtLine(line);
string el;
while( getline(fmtLine, el, ',')){
try{
int sToi = stoi(el);
isInt.push_back(true);
}
catch(invalid_argument& e){
isInt.push_back(false);
}
}
CsvWrapper::setDataTypes(isInt);
}
while(readFile >> line){
++fileLength;
outFile << line << endl;
}
readFile.close();
outFile.close();
split_quicksort<CsvWrapper::CsvLine>(outName, threads, 100000);
auto endClock = Clock::now();
cout << chrono::duration_cast<chrono::seconds>(endClock - startClock).count() << endl;
return 0;
}