-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecimate.cpp
42 lines (33 loc) · 1.03 KB
/
decimate.cpp
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
#include <iostream>
#include <fstream>
#include <string>
#include <regex>
int main() {
std::ifstream inputFile("19.03.24_2_in.csv");
std::ofstream outputFile("19.03.24_2_mod.csv");
if (!(inputFile.is_open()&&outputFile.is_open())) {
std::cerr << "Unable to open file." << std::endl;
return 1;
}
std::string line;
int lineCounter = 0;
std::getline(inputFile, line);
outputFile << line << std::endl; // pass the HEADER
std::regex detection_regex("<_____>");
std::string replacement = "Piket";
bool PRIMED = false;
while (std::getline(inputFile, line)) {
if (line.find(replacement) != std::string::npos) PRIMED = true;
if (lineCounter % 10 == 0) {
if (PRIMED) {
line = std::regex_replace(line, detection_regex, replacement); // <_____> → Piket
PRIMED = false;
};
outputFile << line << std::endl;
}
lineCounter++;
}
inputFile.close();
outputFile.close();
return 0;
}