#1
Code:
while(!inFile.eof())
{
getline(inFile,line);
...
Don't use an eof test to control your loop. Test the result of the getline call itself directly instead.
Code:
while(getline(inFile,line))
{
...
#2
Code:
while(!inFile.eof())
{
getline(inFile,line);
...
infile.close();
This outer loop would only execute once because it closes the file. As such it looks like it would only read the first line of the file.
#3
Code:
while(!inFile.eof())
{
getline(inFile,line);
stringstream lineStream(line);
string bit;
vector<string>DataStore;
while(getline(lineStream, bit, ',')){
DataStore.push_back(bit);
}
I find it curious that your vector is local to the outer loop. Is this intentional? It does not feel right to me.
#4 As for your question, if you truly only wish to store the second column, one option would be to just call getline twice and only store the second string:
Code:
string bit;
vector<string>DataStore;
getline(lineStream, bit, ','); // Get/throw away first column
getline(lineStream, bit, ','); // Get/keep second column
DataStore.push_back(bit); // Store second column in vector