I am trying to write a function that opens a csv path in ifstream and then parse it into a course object that I can then insert into a BST. For some reason that I haven’t figured out yet, the program fails to open the csv and returns before ever hitting the rest of the code. Code below:
void loadBids(string csvPath, BinarySearchTree* bst) {
ifstream inputFile;
inputFile.open(csvPath);
string inputLine;
if (!inputFile.is_open()) {
cout << "Error reading file" << endl;
return;
}
while (getline(inputFile, inputLine))
{
string temp1, temp2, temp3, temp4;
int slot = 0;
stringstream tempString(inputLine);
getline(tempString, temp1, ',');
getline(tempString, temp2, ',');
getline(tempString, temp3, ',');
getline(tempString, temp4, ',');
if (temp1 == "" || temp2 == "") {
I have tried:
ifstream inputFile(csvPath)
inputFile.open(csvPath,ios::in)
as well as shifting the conditional to a if file is open vice not open.
I am kinda at a loss at this point Any help would be appreciated.
New contributor
toymachine4321 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.