csv file parsing with commas in string that is separated by commas RRS feed

  • Question

  • User-2132746437 posted

    I'm parsing a CSV file and we just got a new file and it has values that has commas in it, and the values are separated by commas. How can I still split by commas but keep my comma in the value?


    "@","value1","value2","value3,value4","value5", "$'

    I need to grab "value3, value4" and place it into my table column but still keep each value in the correct index, so that value4 doesn't go into the value5 field.

    what I currently have:

    string[] lines = all.Split(new string[] { "\"@\",", ",\"$\"" }, StringSplitOptions.RemoveEmptyEntries);
     string x = lines[i];
     string[] t = x.Split(',');

    Thursday, May 18, 2017 8:21 PM

All replies