0

I have a CSV file like this:

"1","Item-1, This is First Item", "10,500.00"
"2","Item-2, This is 2'nd "symbol within column field "Item", "10,500.00"

I want each value enclosed in "" seprated by a comma to be treated as a column. Please note "" can be within a data field.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • 1
    Please read [ask] next time. There's a lot missing from your question, basically it's asking for a code dump. However, this question has been answered plenty of times before, so you can find your answer [here](http://stackoverflow.com/questions/2081418/parsing-csv-files-in-c-sharp). It'd be really helpful if for your next question you share your research. – CodeCaster Feb 04 '16 at 15:43
  • My Apologies for this question CodeCaster but if you may read my question its just not simple csv parsing and some how i could not understand what should be the correct search string to my eg data csv parsing and not understand from where to start with i tried to seek help for some reference to understand from where to begin. Thanks for the link but as i said that just explains how to parse a csv file but does not answer how i parse the given sample data as it has delimitter character in the field text content as well. – Gagan Bhatia Feb 06 '16 at 12:23
  • Did you read the answers to the question that I linked you to? There are quite a few libraries that can parse your CSV for you with a handful of lines of code. You **don't** wan't to write that parsing code yourself. Also, you can search the web for "C# parse CSV" and you'll find plenty of results. – CodeCaster Feb 06 '16 at 12:54
  • Yes i made it a point to go through the link before replying here let me know if i missed something, there are references to some libaries but then no where there i could see either a similar problem posted or a suggestion tht those libaries can do wht i need this implies im still there in the wild to first either check each and every library to see if it can do the needful, i had myself parsed csv data plenty of times with lib i'm here on stackover flow to get some quick tips from experts like you which help me get to the solition quicker and precise when a google search is not enough – Gagan Bhatia Feb 06 '16 at 17:05
  • Every CSV parsing library shown in that Q&A supports data where the separator character is quoted in values. Stack Overflow does not exist to "get help real quick", you must show what you have tried. If you just try any library from the linked question, you'll see it works. – CodeCaster Feb 06 '16 at 17:17
  • Please review the data presented here my sample data has quotes with in the text field also even comma so if either of them is used as a field seprator data would not be parsed correctly the qualified field seperator should be only when comma is present before and after the quotes – Gagan Bhatia Feb 06 '16 at 17:20
  • 1. Read [ask], your question does not contain enough information. It's asking for a code dump, you're not going to get that. 2. [edit] your question to show what you have tried. 3. I'm quite sure that if you test a library from the [linked question](http://stackoverflow.com/questions/2081418/parsing-csv-files-in-c-sharp), it'll solve your problem. – CodeCaster Feb 06 '16 at 17:24
  • Thanks so much for your kind suggestions. As i said i came here for a quick suggestion/direction and no code dump. I can try to post wht i tried if it takes me forward one step and jm stuck in between but just posting some thing knowingly its not the right direction just to satisfy the protocol of try before u ask seems some what not very convincing to me still i honour the rules if it disallows me to put up a question. Thanks a lot. – Gagan Bhatia Feb 06 '16 at 17:42
  • There are infinite ways to do this. If you show your code, we can help fix it. – CodeCaster Feb 06 '16 at 17:49

0 Answers0