Hi,
I am trying to get information from a CSV file, and import it into my program. The code I have so far is listed below:
How does this look? Im very new to coding, so I was wondering if anyone might be able to give some input on how I can do the CSV parsing. Are there tutorials online for this? Would anyone be able to give some insight?Code:#include <iostream> #include <fstream> #include <string> using namespace std; int main () { string line; //this will contain the data read from the file ifstream myfile ("example.csv"); //opening the file. if (myfile.is_open()) //if the file is open { while (! myfile.eof() ) //while the end of file is NOT reached { getline (myfile,line); //get one line from the file //DO THE CSV PARSING HERE. //FOR NOW I WILL JUST OUTPUT THE LINE: cout << line << endl; //and output it } myfile.close(); //closing the file } else cout << "Unable to open file"; //if the file is not open output <-- return 0; }
Regards,
James



LinkBack URL
About LinkBacks



