I had to split string data based on Comma.
This is the excel data:-
Please find the excel data
string strCurrentLine=””Himalayan Salt Body Scrub with Lychee Essential Oil from Majestic Pure, All Natural Scrub to Exfoliate & Moisturize Skin, 12 oz”,SKU_27,”Tombow Dual Brush Pen Art Markers, Portrait, 6-Pack”,SKU_27,My Shopify Store 1,Valid,NonInventory”.
Regex CSVParser = new Regex(“,(?=(?:[^”]“[^”]“)(?![^”]“))”);
string[] lstColumnValues = CSVParser.Split(strCurrentLine);
I have attached the image.The problem is I used the Regex to split the string with comma but i need the ouptut just like SKU_27 because string[0] and string2 contains the forward and backward slash.I need the output string1 and remove the forward and backward slash.
2
Answers
The file seems to be a CVA file. For CVA to be properly formatted, it will use quotes “” to wrap strings that contains comma, such as
Simply split the string by comma, you will get the 2nd column with double quote.
I’m not sure whether you are asking how to remove the double-quotes from
lstColumnValues[0]
andlstColumnValues[2]
, or add them tolstColumnValues[1]
.To remove the double-quotes, just use
Replace
:If you need to add them: