diff --git a/csvfile.hpp b/csvfile.hpp index 2c374f5..a90bbfd 100755 --- a/csvfile.hpp +++ b/csvfile.hpp @@ -65,10 +65,9 @@ class csvFile { return write(val); } - template - static std::vector> parse(const std::filesystem::path &csvFilepath) + static std::vector> parse(const std::filesystem::path &csvFilepath) { - std::vector> resultCSV; + std::vector> resultCSV; if (!std::filesystem::exists(csvFilepath)) { std::cerr << "The file does not exist:" << csvFilepath.string() << std::endl; return resultCSV; @@ -79,21 +78,17 @@ class csvFile { std::cerr << "Can't open file:" << csvFilepath.string() << std::endl; return resultCSV; } - std::vector row; + std::vector row; std::string line; using Tokenizer = boost::tokenizer>; while (std::getline(inputfile, line)) { Tokenizer tokenizer(line); - row.resize(std::distance(tokenizer.begin(), tokenizer.end())); - std::transform(tokenizer.begin(), tokenizer.end(), row.begin(), [](const std::string &el) { - return boost::lexical_cast(el); - }); - // std::cout << std::endl; - // row.assign(tokenizer.begin(), tokenizer.end()); - // for (const auto &el : row) { - // std::cout << el << " "; - // } - // std::cout << std::endl; + const int numOfCols = std::distance(tokenizer.begin(), tokenizer.end()); + row.resize(numOfCols); + std::copy(tokenizer.begin(), tokenizer.end(), row.begin()); + // std::transform(tokenizer.begin(), tokenizer.end(), row.begin(), [](const std::string &el) { + // return boost::lexical_cast(el); + // }); resultCSV.push_back(row); }