I want to split the lines of a .csv file in which data is comma-separated. I wrote the following function
const char DELIMITER = ',';
vector <string> split (string input)
{
stringstream SS(input);
vector <string> splitedWords;
string word;
while (getline(SS, word, DELIMITER))
splitedWords.push_back(word);
return splitedWords;
}
It works properly as long as there is no space character in the line but when a phrase includes a space character the function ends working. See the model inputs and outputs;
intput: this,is,a,test
output: {this, is, a, test} --> TRUE output
input: this,is not,a,test
output: {this, is} --> FALSE output --> Desired output: {this, is not, a, test}