Below is some sample lines of a csv file.I am only interested in the second, third and fourth columns. So I want to write a c++ program to extract these elements and push them to a struct I defined. Currently I know how to get the whole line, but don't know how to get a certain column.
How can I extract these columns?
1,4872,4873,0.19109237,f,
2,4874,4875,0.2774146,f,
3,4876,4877,0.1637944,f,
4,4878,4881,0.07772251,f,
5,4881,4879,0.1285009,f,
6,4880,4881,0.13613093,f,
My code to open the file and read lines:
void ReadGraph_FromTXT()
{
ifstream graphData("new_network.csv");
string line;
while (getline(graphData, line)){
cout << line << endl;
}
}