Is there a way to find out how long a line is in my csv file (e.g. how many variables). I'm reading the data into a string and then using stringstream (a method a picked up from this excellent forum!) to input into an array:
Also, is this method accurate, as when I'm debugging and stepping through I see values change ever so slightly from what they are in the CSV file.Code:std::ifstream ifs(filename); std::string line, field; double* pArray = new double[11]; std::getline(ifs,line); std::stringstream ss(line); for(int i=0; i<11; i++) { ss>>pArray[i]; std::getline(ss,field,','); }
e.g.
0.4 in a CSV would be 0.4000000002




Reply With Quote