I'm using GeeksForGeeks ReadCSV function to read CSV files, I copied the code exactly as it is and I get this error: "no instance of "getline" matches the argument list" can anyone provide me with why it happens?
Here's the full code:
void ReadCSV(std::string filename, std::vector<RowVector*>& data)
{
data.clear();
std::ifstream file(filename);
std::string line, word;
// determine number of columns in file
getline(file, line, '\n');
std::stringstream ss(line);
std::vector<Scalar> parsed_vec;
while (getline(ss, word, ', ')) {
parsed_vec.push_back(Scalar(std::stof(&word[0])));
}
uint cols = parsed_vec.size();
data.push_back(new RowVector(cols));
for (uint i = 0; i < cols; i++) {
data.back()->coeffRef(1, i) = parsed_vec[i];
}
// read the file
if (file.is_open()) {
while (getline(file, line, '\n')) {
std::stringstream ss(line);
data.push_back(new RowVector(1, cols));
uint i = 0;
while (getline(ss, word, ', ')) {
data.back()->coeffRef(i) = Scalar(std::stof(&word[0]));
i++;
}
}
}
}