I haven't programmed in a while and am trying to work on a project which will read in tweets from a csv file and then manipulate what is stored. Currently, I am trying to just extract the data from the file and print to the console. I know that my file is opening because I had included a conditional statement, however, when it comes to reading the data rather than getting any actual information I am just getting blank lines. I also thought it could be because the csv file I am working with is quite large (20k data entries) so I added in a for loop to try and isolate the problem.
I am using getline and stringstream to get the data out, and cout to print to console. I just can't seem to find the issue.
Here is my code:
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
int main() {
    string line;
    ifstream fin;
    fin.open("train_dataset_20k.csv");
    if (!fin.is_open()){
        cout << "Error opening file" << endl;
        return 1;
    }
    while(fin.is_open()){
        for (int i = 0; i <10; i ++){
            string Sentiment,id,Date,Query,User,Tweet;
            stringstream lineSS(line);
            getline(lineSS, Sentiment, ',');
            getline(lineSS, id, ',');
            getline(lineSS, Date, ',');
            getline(lineSS, Query, ',');
            getline(lineSS, User, ',');
            getline(lineSS, Tweet, '\n');
            cout << Sentiment << endl;
            cout << id << endl;
            cout << Tweet << endl;
        }
        fin.close();
    }
    return 0;
}
Currently, it will run through the for loop 10 times, but will just output blank lines with no information in it.
 
    