I am trying to take in a lot of data from multiple files and I use getline() to take the entire line to put it into a temporary string value and turn the data from the line into an object(everything is already sorted).
void charts(vector<Song> &data, int menuop){
ifstream stream;
if(menuop == 1){
stream.open("charts_top50_1960_1980.csv");
assert(stream.fail() == false);
data.clear();
}
else if(menuop == 2){
stream.open("charts_top50_1981_2000.csv");
assert(stream.fail() == false);
data.clear();
}
else if(menuop == 3){
stream.open("charts_top50_2001_2020.csv");
assert(stream.fail() == false);
data.clear();
}
string tempstring;
while(getline(stream, tempstring)){
for(int i = 0; i < tempstring.length(); i++){
if(tempstring[i] == '/'){
tempstring[i] == ',';
}
}
//cout << tempstring << endl;
Song tempsong(const &tempstring);
data.push_back(tempsong);
}
stream.close();
}