I am trying to read data from an Excel file saved in csv format, my Excel file has six rows and 49 columns, as you can see in the photo:
I want to read data from that file, I'm doing this code:
ifstream inFile;
inFile.open("datacsvformatdelimitadoporcomas.csv");
string nombre2="factura";
string b= ".xml";
string suma= nombre2+ b;
ofstream fout(suma.c_str());
vector<string> cabeceras;
string campo;
string line;
while(getline(inFile, line)){//coges linea por linea
istringstream s(line);
string field;
while (getline(line,campo,';')) {
cabeceras.push_back(campo);
}
}
for(int i=0;i<cabeceras.size();i++){
cout<<cabeceras[i]<<endl;
}
However, I get errors when compiling:
The error is this:
no matching function for call to 'getline(std::string&, std::string&, char)'
Referring to this first line:
while (getline(line,campo,';'))
I have taken away the; but in the same way I still get the error.