Hello,
I am new to proogramming and I need read the elements from two csv files into a 2 vectors and display the elements of vectors.
The csv file is in the following fomat:
200, New york, -23.456, 23.455
201,Chicago,-34.5434,34.546
.....
.....
After that I have to perform string matching on the elements of the two vectors
I have used the collowing code to read the csv file into vector:
#pragma warning(disable: 4786) // VC++ 6.0 disable warning about debug line too long
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
typedef vector<string> LINE;
int main()
{
string line;
int pos;
vector<LINE> array;
ifstream in("log.csv");
if(!in.is_open())
{
cout << "Failed to open file" << endl;
return 1;
}
while( getline(in,line) )
{
LINE ln;
while( (pos = line.find(',')) >= 0)
{
string field = line.substr(0,pos);
line = line.substr(pos+1);
ln.push_back(field);
}
array.push_back(ln);
}
return 0;
}
What modification I should make to this code so that I can display all the elements in the above vector.
Also how can a particular element be accessed when necessary. i.e how could I access the element Chicago.
Please give me any clues with the string matching of elements of two vectors also if possible
I am struck in this and I desperately need your help. Thankyou