-1

Example of text:

OUTPATIENT VISIT 4,Private,1,1,0,60,0,0
OUTPATIENT VISIT 4,Private,1,1,0,"1,260",0,0

At the moment I'm just separating the string like so:

std::stringstream ss(checkLine);

        getline(ss, something, ',');
        getline(ss, somethingElse, ',');
        getline(ss, somethingElse1, ',');
        getline(ss, somethingElse2, ','); 
        getline(ss, somethingElse3, ','); 
        getline(ss, somethingElse4, ','); 
        getline(ss, somethingElse5, ','); 
        getline(ss, somethingElse6, ',');   

The way I'm doing it works for the first line of text but when it comes to the second line is goes to crap. There are a ton more lines its not only 2

I need to store each parsed section of the string onto its own string. How do I use the commas as delimiter and also deal with numbers using comma as a thousands separator?

2 Answers2

2

You could use the sequence ", " as delimiter. By adding the space after the comma you filter out the second part of numbers.

strpeter
  • 2,562
  • 3
  • 27
  • 48
typeid
  • 29
  • 7
0

You could use "," as delimiter and do a second pass where you will merge string containing digit (using std::isdigit per example).

Light
  • 308
  • 2
  • 6