#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <cstdio>
constexpr std::size_t minfields{33};
std::vector<std::string> splitStr(const std::string& line, const char delimiter = ',')
{
std::vector<std::string> splitLine;
splitLine.reserve(minfields);
std::istringstream ss(line);
std::string buf;
while (std::getline(ss, buf, delimiter)) {
splitLine.push_back(buf);
}
return splitLine;
}
int main(int argc, char* argv[])
{
if(argc < 3)
{
exit(EXIT_SUCCESS);
}
std::ifstream inFile(argv[1]);
FILE* outFile = fopen(argv[2], "w");
std::string line;
while(std::getline(inFile,line))
{
auto split = splitStr(line, ';');
if(split[3][0] == 'E' || split[3][0] == 'T')
{
fprintf(outFile, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
split[0].c_str(),
",",
split[1].c_str(),
",",
split[3].c_str(),
",",
split[4].c_str(),
",",
split[5].c_str(),
",",
split[6].c_str(),
",",
split[10].c_str(),
",",
split[9].c_str(),
",",
split[11].c_str(),
",",
split[7].c_str(),
",",
split[32].c_str(),
"\n");
}
}
inFile.close();
fclose(outFile);
}
I2luY2x1ZGUgPGZzdHJlYW0+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxzc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGlvPgoKY29uc3RleHByIHN0ZDo6c2l6ZV90IG1pbmZpZWxkc3szM307CgpzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4gc3BsaXRTdHIoY29uc3Qgc3RkOjpzdHJpbmcmIGxpbmUsIGNvbnN0IGNoYXIgZGVsaW1pdGVyID0gJywnKQp7CiAgICBzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4gc3BsaXRMaW5lOwogICAgc3BsaXRMaW5lLnJlc2VydmUobWluZmllbGRzKTsKICAgIHN0ZDo6aXN0cmluZ3N0cmVhbSBzcyhsaW5lKTsKICAgIHN0ZDo6c3RyaW5nIGJ1ZjsKICAgIHdoaWxlIChzdG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aXRbMTFdLmNfc3RyKCksCiAgICAgICAgICIsIiwKICAgICAgICAgc3BsaXRbN10uY19zdHIoKSwKICAgICAgICAgIiwiLAogICAgICAgICBzcGxpdFszMl0uY19zdHIoKSwKICAgICAgICAgIlxuIik7CiAgICAgICAgfQogICAgfQogICAgaW5GaWxlLmNsb3NlKCk7CiAgICBmY2xvc2Uob3V0RmlsZSk7Cn0K
Main.java:1: error: illegal character: '#'
#include <fstream>
^
Main.java:1: error: class, interface, or enum expected
#include <fstream>
^
Main.java:2: error: illegal character: '#'
#include <string>
^
Main.java:3: error: illegal character: '#'
#include <vector>
^
Main.java:4: error: illegal character: '#'
#include <sstream>
^
Main.java:5: error: illegal character: '#'
#include <cstdio>
^
Main.java:9: error: class, interface, or enum expected
std::vector<std::string> splitStr(const std::string& line, const char delimiter = ',')
^
Main.java:12: error: class, interface, or enum expected
splitLine.reserve(minfields);
^
Main.java:13: error: class, interface, or enum expected
std::istringstream ss(line);
^
Main.java:14: error: class, interface, or enum expected
std::string buf;
^
Main.java:15: error: class, interface, or enum expected
while (std::getline(ss, buf, delimiter)) {
^
Main.java:17: error: class, interface, or enum expected
}
^
Main.java:19: error: class, interface, or enum expected
}
^
Main.java:26: error: class, interface, or enum expected
}
^
Main.java:28: error: class, interface, or enum expected
FILE* outFile = fopen(argv[2], "w");
^
Main.java:30: error: class, interface, or enum expected
std::string line;
^
Main.java:31: error: class, interface, or enum expected
while(std::getline(inFile,line))
^
Main.java:34: error: class, interface, or enum expected
if(split[3][0] == 'E' || split[3][0] == 'T')
^
Main.java:59: error: class, interface, or enum expected
}
^
Main.java:62: error: class, interface, or enum expected
fclose(outFile);
^
Main.java:63: error: class, interface, or enum expected
}
^
21 errors