You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
#include "util.h"
|
|
|
|
std::array<std::vector<std::string>, 2> read_csv(const std::string& filename) {
|
|
std::array<std::vector<std::string>, 2> array_vectors;
|
|
std::vector<std::string> vec_option;
|
|
std::vector<std::string> vec_opcision;
|
|
std::ifstream file(filename);
|
|
std::string line;
|
|
char delimiter = ',';
|
|
getline(file, line);
|
|
while (std::getline(file, line)) {
|
|
std::stringstream stream(line);
|
|
std::string option;
|
|
std::string opcision;
|
|
getline(stream, option, delimiter);
|
|
getline(stream, opcision, delimiter);
|
|
vec_option.push_back(option);
|
|
vec_opcision.push_back(opcision);
|
|
}
|
|
array_vectors[0] = vec_option;
|
|
array_vectors[1] = vec_opcision;
|
|
return array_vectors;
|
|
}
|
|
|
|
std::string call(std::string cmd) {
|
|
FILE *fp;
|
|
int status;
|
|
char path[PATH_MAX] = {0};
|
|
fp = popen(cmd.c_str(), "r");
|
|
if (fp == NULL) {
|
|
exit(1);
|
|
}
|
|
while (fgets(path, PATH_MAX, fp) != NULL) {
|
|
break;
|
|
}
|
|
status = pclose(fp);
|
|
if (status == -1) {
|
|
exit(1);
|
|
}
|
|
return path;
|
|
} |