CSV Parsing

前端 未结 13 2081
攒了一身酷
攒了一身酷 2020-12-17 04:45

I am trying to use C# to parse CSV. I used regular expressions to find \",\" and read string if my header counts were equal to my match count.

Now this

相关标签:
13条回答
  • 2020-12-17 05:47

    In order to have a parseable CSV file, any double quotes inside a value need to be properly escaped somehow. The two standard ways to do this are by representing a double quote either as two double quotes back to back, or a backslash double quote. That is one of the following two forms:

    ""

    \"

    In the second form your initial string would look like this:

    "a","\"b\",\"x\",\"y\"","c"

    If your input string is not formatted against some rigorous format like this then you have very little chance of successfully parsing it in an automated environment.

    0 讨论(0)
提交回复
热议问题