Manju Venkat wrote:yes. i want to remove the commas and commas within double quotes should not be removed.requirement is like that.
but the output file is fixed format. means if any field is having spaces, it will move spaces to whole length of the field.so i think no problem will be there in the output file.
Reading this again, it is still not clear to me. "Yes" is the answer to my question, that you are not concerned about loosing the distinction between a field and a string of characters. Then in the second paragraph, you talks about fields.
For fields, I would suggest a different method.
Anyway, code outline as provided can still give you problems. Presumably this has come from some user application which can "export" a CSV. The problem is, if there is a human putting the data in, are they restricted to only messing you about with embedded commas? What about embedded quotes? Such a thing would mess up that code, whether or not in a field bounded by quotes.
Without full knowledge of the possible inputs, the program code is more complicated. If a quote can occur in the data (if it is user typing, it will occur unless prevented) you have to also know that only quotes that are in an expected delimiting position should be treated as delimiters. Except, what about a necessary quote in the first position? And then, if you are looking for quotes as delimiters (so, something like ", or ,") what if one of those combinations occurs in the text? So in the end, you have to start from the beggining and make fields, also start from the end of the line and make other fields, and see if they are the same, and decide what to do if not.
As I have said, much simpler just to get a "text" file exported instead of the CSV, if at all possible. If not, you need a full specification of the possible data. Then maybe we can see again.