Hi
is there anyone have an idea :idea: on how could i get the column 7 from the file, I did it for column 5. or how could I continue to make it take other columns.
if ( input_file.fail ())
{
cout << "Error opening file.";
}
else
{
for(int i = 0; i < 7; i++) // Scan the first 7 lines, which is not required
getline(input_file, line, '\n');
count = 8; // We are in the eighth line
while(count <= 1447)
{ // We have to add until 1447 lines..
for(int i = 0; i < 5; i++)
getline(input_file, line, ','); // Get the first 5 columns.
cout<<line<<endl; // Print the 5th column for verification.
value = atof(line.c_str());// Convert the 5th column into float
sum += value; //add value to sum
getline(input_file, line, '\n'); // Go to the next line..
count++; // Increment the count, to go to the next line
}
cout << count;
cout<<endl<<"The sum of all values of column 5 is : "<<sum<<endl;
float avg = sum / count ;
cout<<endl<<"The avg of all values of column 5 is : "<<avg<<endl;
}
thank you