This repository was archived by the owner on Jul 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_script.cpp
More file actions
75 lines (63 loc) · 2.24 KB
/
Copy pathexample_script.cpp
File metadata and controls
75 lines (63 loc) · 2.24 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
67
68
69
70
71
72
73
74
75
/**
* Example script showing usage of the `classifyColumns` function on data files specified by hard-coded paths.
*
* @author Duncan Mazza
*/
#include "tabulated_data_inference.h"
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
int getFileLines(const string &target, vector<string> &ret) {
string line;
ifstream targetFile(target);
if (targetFile.is_open()) {
while (getline(targetFile, line)) {
ret.push_back(line);
}
targetFile.close();
} else {
cerr << "Could not open file " << target << " (skipping)" << endl;
return 0;
}
return 1;
}
int main() {
vector<string> fileTargets{ // Populate this vector with the files to parse
R"(tests/test_targets/xf-naca2408-il-50000.csv)",
R"(tests/test_targets/acsm_shortened.csv)"
};
vector<vector<string>> filesLines;
size_t fileIdx = -1;
for (const auto &target: fileTargets) {
fileIdx++;
vector<string> fileLines;
if (!getFileLines(target, fileLines)) { continue; }
filesLines.push_back(fileLines);
}
fileIdx = -1;
auto parser = MpcParserTWrapper();
for (const auto &thisFileLines: filesLines) {
fileIdx++;
cout << "Parsing " << fileTargets.at(fileIdx) << endl;
cout << "Finding delimiter..." << endl;
auto delimRet = getDelim(thisFileLines);
cout << "Finding fields..." << endl;
vector<vector<string>> fieldRet;
int consistentFields = getFields(thisFileLines, get<0>(delimRet), fieldRet, get<1>(delimRet));
if (!consistentFields) {
cout << "Could not find a consistent number of fields in " << fileTargets.at(fileIdx) << endl;
}
cout << "Classifying fields..." << endl;
vector<tuple<string, FieldCls>> classificationRet;
classifyColumns(fieldRet, classificationRet, parser);
cout << "Data insights for " << fileTargets.at(fileIdx) << ":" << endl;
for (auto classification: classificationRet) {
cout << " - " << get<0>(classification) << " (" << FieldClsCorrespondingNames[get<1>(classification)] << ")"
<< endl;
}
cout << endl;
}
return 0;
}