Reading Excel Row Cells A through J
Hello again all. I would like to know how I can read from an excel cell then move over to the next column and get that data. Is it possible? below is the code i have and where im stuck.
Code:
#include<iostream.h>
#include<fstream.h>
void main()
{
//variables to store in the mean
float mean = 0.0;
//open up file
ifstream inFile;
inFile.open("gene.csv", ios:in);
//verify open was sucessful
if(!inFile.fail())
{
//read cell a1 through j1
inFile >> Row 1 cell A through Row 1 cell J //i know this is wrong
only calcs the first line
it actually works but it only calculates the first line. how can i make it read the 1st line in "healthy.txt" then display the mean and go to the 2nd line etc... and display each mean for the 2000 rows?
btw im using visual studio c++ 6.0 if that helps.
Code:
//Jared Fire
//Find the Mean for the Gene
#include<iostream.h>
#include<fstream.h>
void main()
{
//might need variables to store in the mean
float mean = 0.0;
float cell1= 0.0;
float cell2= 0.0;
float cell3= 0.0;
float cell4= 0.0;
float cell5= 0.0;
float cell6= 0.0;
float cell7= 0.0;
float cell8= 0.0;
float cell9= 0.0;
float cell10= 0.0;
//begin for loop
for(short i=0;i<=2000;i++){
i++;
//open up file
ifstream inFile;
inFile.open("healthy.txt");
//verify open was sucessful
if(!inFile.fail()) //ifopen did not fail
{
//read cell a1 through j1
inFile >> cell1 >> cell2 >> cell3 >> cell4 >> cell5 >> cell6 >> cell7 >> cell8
>> cell9 >> cell10;
//calculate the mean for ROW and place in mean variable
mean = (cell1+cell2+cell3+cell4+cell5+cell6+cell7+cell8+cell9+cell10)/10;
}
//open up file to write data to
ofstream outFile;
outFile.open("mean.txt",ios::app);
//verify open sucessful
if(!outFile.fail())//if open did not fail
{
//write the mean variable into cell
cout << mean << endl;
mean = 0.0;
}
}//endforloop
}//end main