I have a file which has some comma separated rows. I want to get each value in a line (like columns in CSV). I tried to read that with following c++ code:
while (ip.good())
{
getline(ip, pid, ',');
getline(ip, npid, ',');
getline(ip, fid, ',');
getline(ip, nfid, ',');
getline(ip, sys, ',');
getline(ip, gf, '\n');
}
and the file likes following:
2374447,1,2374448,3,16,300
2374447,1,2374449,3,16,300
2374447,1,2374450,3,16,300
2374447,1,2374451,3,16,300
2374447,1,2374452,3,10,300
2374447,1,0,4,20,300
2374447,1,2374453,3,10,300
it reads last line twice or read a empty line as last line! I added one line at the end of the file like: a,a,a,a,a,a. now it read all the lines correctly but returns two extra empty lines. does anyone what's the problem with that?