Empty field read in my CSVread function

This is my CSV read function in c++.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
vector<vector<string> > CSVRead(string fname,char const row_delim, char const field_delim)
{
    ifstream input(fname.c_str());

    typedef vector<vector<string> > Rows;
  Rows rows;

    //char const row_delim = '\n';
//char const field_delim = ',';
for (string row; getline(input, row, row_delim); ) {
  rows.push_back(Rows::value_type());
  istringstream ss(row);


  for (string field; getline(ss, field, field_delim); ) {
    rows.back().push_back(field);
  }
}
return rows;
}

This function doesn't working for empty field. For example , My data will be like this means, xxx,yyy,,zzz,,,,,aaa aaa,xxx,ddd,,ddd,,,bbb

My first row terminating after reading the data "yyy". The next empty data doesn't pushed in the vector. But i need to push empty data also in the vector. How can i do this ?
Topic archived. No new replies allowed.