Need help to parse the csv file with comma delimiter

Hello Friends,

I am facing issues in parsing the csv file,and I would be really grateful if anyone can provide the inputs..

Problem Description ::

I am able to parse the file correctly with the following type of lines..

"ABC","ANGEL",DEMONS,

using istringstream lineparse(line) and getline (lineparse,value, ',') I am able to seperate out the values and store it in vector...

But if the line contains the values as mentioned below::

"ABC","ANGEL,DEMONS",DEMONS,

The above method will give the result which is not the intended result.

I want the value to be seperated out as ::

ABC
ANGEL,DEMONS
DEMONS

I would be really grateful if anyone can give me some inputs on how we can parse the above line...

With Best Regards,
Jinu
Last edited on
Add a small hint to your program. After a comma, if the first character is a ", then keep looping till you find another one, and concatenate the letters from the first " to the last ". Could you do that?
Hi,

Thank you so much for your time and for looking into the problem.

I will check the way you have mentioned....But currently I am using the function istringstream lineparse(line) and getline (lineparse,value, ',') to parse the comma seperated file..

Will it not complicates the solution....? just asking....But I would like to try the way you have mentioned..

With Best Regards,
Jinu
If you're parsing with that function, you may try this. Parse first for ", then parse for commas, and then concatenate the different parts.

(lineparse,value, '\"') //slash because it's a special character.
Thankyou so much for your help.....I think this shoud work...:) ..I will try this way..

WIth Very Best Regards,
Shailesh.
rror: invalid conversion from `void*' to `char**'
csvreader.cc:21: error: cannot convert `std::string' to `size_t*' for argument `2' to `__ssize_t getline(char**, size_t*, FILE*)'


if I am using (lineparse,value, '\",')
Last edited on
You're welcome :)
rror: invalid conversion from `void*' to `char**'
csvreader.cc:21: error: cannot convert `std::string' to `size_t*' for argument `2' to `__ssize_t getline(char**, size_t*, FILE*)'


Getting this error..:( if I am using (lineparse,value, '\",')
Topic archived. No new replies allowed.