StringStream Not Reading But Once

What I'm Trying To Do:
1. Read CSV file into string
2. Iterate string and replace commas found within values with a pipe
3. Funnel resulting string into a stringstream so I can use getline on it
4. Pull from stringstream using getline, and putting the data into appropriate
class member (which is in turn stored in a linked list)
5. Rinse/repeat until end of file is reached.

What I'm getting:
The code is reading in the first line of the CSV (which has about 5000
records), and working just fine. However, after that, it's pulling
everything, but not outputting it to the class member variables. ANY idea
what's going on? The cout << value statement is outputting the correct
information on every iteration, which means the stringstream iStream has
the information, but hoCustID is only outputting the first instance of
record. Everything appears to be written correctly, but, obviously not...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
  if(fin.is_open()) {
    while(!fin.eof()) {
    getline(fin, record);
    iter->next = new Record;
    iter = iter->next;
    iter->next = NULL;
    value = "";

    for(size_t i = 0;i < strlen(record.c_str());i++) {
      if(record[i] == '"') {        
        if(qFound == true) {
          qFound = false;
        }
        else {
          qFound = true;
        }
      }
      if(record[i] == ',') {
        if(qFound == true) {
          record[i] = '|';
          }
      }
      value += record[i];
    }

    iStream.str("");
    iStream.str(value);
    cout << value << endl << endl;
    getline(iStream, iter->storeNum, ',');
	  getline(iStream, iter->verNum, ',');
	  getline(iStream, iter->curBusDate, ',');
	  getline(iStream, iter->clientID, ',');
	  getline(iStream, iter->hoCustID, ',');
	  getline(iStream, iter->custType, ',');
	  getline(iStream, iter->custName, ',');
    for(size_t i = 0;i < strlen(iter->custName.c_str());i++) {
      if(iter->custName[i] == '|') {
        iter->custName[i] = ',';
      }
    }
	  getline(iStream, iter->custDOB, ',');
	  getline(iStream, iter->custMailAddress1, ',');
	  getline(iStream, iter->custMailAddress2, ',');
	  getline(iStream, iter->custMailApt, ',');
	  getline(iStream, iter->custMailCity, ',');
	  getline(iStream, iter->custMailState, ',');
	  getline(iStream, iter->custMailZip, ',');
	  getline(iStream, iter->custEmail, ',');
	  getline(iStream, iter->custPhone1, ',');
	  getline(iStream, iter->custExt, ',');
	  getline(iStream, iter->custDemo1, ',');
	  getline(iStream, iter->custDemo2, ',');
	  getline(iStream, iter->custDemo3, ',');
	  getline(iStream, iter->custDemo4, ',');
	  getline(iStream, iter->custDemo5, ',');
	  getline(iStream, iter->custDemo6, ',');
	  getline(iStream, iter->custDemo7, ',');
	  getline(iStream, iter->custDemo8, ',');
	  getline(iStream, iter->custDemo9, ',');
	  getline(iStream, iter->custDemo10, ',');
	  getline(iStream, iter->custDemo11, ',');
	  getline(iStream, iter->custDemo12, ',');
	  getline(iStream, iter->cust1stRentDate, ',');
	  getline(iStream, iter->raNum, ',');
	  getline(iStream, iter->raStatus, ',');
	  getline(iStream, iter->raSwitchOutDate, ',');
	  getline(iStream, iter->raDate, ',');
	  getline(iStream, iter->raInactiveDate, ',');
	  getline(iStream, iter->raPaymentMode, ',');
	  getline(iStream, iter->raPayoutDate, ',');
	  getline(iStream, iter->raNextDueDate, ',');
	  getline(iStream, iter->waiverFeeFlag, ',');
	  getline(iStream, iter->wkRate, ',');
	  getline(iStream, iter->moRate, ',');
	  getline(iStream, iter->smRate, ',');
	  getline(iStream, iter->accumRent, ',');
	  getline(iStream, iter->pastDue1, ',');
	  getline(iStream, iter->pastDue2, ',');
	  getline(iStream, iter->pastDue3, ',');
	  getline(iStream, iter->pkgCode, ',');
	  getline(iStream, iter->type, ',');
	  getline(iStream, iter->subType, ',');
	  getline(iStream, iter->clubFeeFlg, ',');
	  getline(iStream, iter->clubLevel, ',');
	  getline(iStream, iter->clubStartDate, ',');
	  getline(iStream, iter->clubTermDate, ',');
	  getline(iStream, iter->clubNextDueDate, '\n');
    cout << iter->hoCustID << endl;
    }
    fin.close();
Topic archived. No new replies allowed.