Hello everyone
can anyone help me to find what is the error in my code, I built a function that get the date from te first column in the csv file, and then call this function in the main program.
the problem is getting many error and not getting the date from the first coulmn.
please help me.
thank you for all your effort .Code:
string GetdateValue(int column,string line)
{
stringstream sstr(line);
string temp[9];
for( int i = 0; i < column; ++i )
getline(sstr,temp,',');
return itoa(i,temp,9);
}
int main()
{
ifstream input_file("L_05.csv");// is a scv file have many coulmn first column of it is the date
string line;
int count;
string field[] = {1};
const int date_SIZE = sizeof date / sizeof *date;
string date[date_SIZE];
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);
count = 8; // We are in the eighth line
while(count <= 1447) // We have to add until 1447 lines..
{
getline(input_file,line);
// number of elements in the above array
for(int cold = 0; cold < date_SIZE; cold++)
{
date[cold] = GetdateValue(field[cold],line);
}
count++; // Increment the count, to go to the next line
}
count -= 8;
for(i = 0; i < date_SIZE; i++)
{
cout << " date " << field [i] << "is "<< date[i] << endl;
}
}
return 0;
}