Parsing commas in field with TextFieldParser causes extra column
<p>Following on a previous thread <a href="https://stackoverflow.com/questions/36570447/object-reference-on-array-with-regex-replace">Object reference on array with regex.replace()</a></p>

<p>I have few columns in <code>cpath</code> which contain fields such as <code>street,""test,format"", casio</code> . Unfortunately,</p>

<pre><code>csvReader.SetDelimiters(new string[] { "," });
</code></pre>

<p>adds empty extra columns to the <code>DataTable</code> <code>csvData</code> because of the comma between <code>test and format</code>. Hence the the following interrogation:</p>

<p>Does a trick exist to remove the comma from <code>"""test,format"""</code> so as to get <code>street,""test format"", casio</code> in <code>csvData</code>?</p>

<p>Thanks in advance</p>

<p><strong>EDIT</strong></p>

<pre><code>private static List&lt;string[]&gt; RemoveComaDataFromCSVFile(string csv_file_path)
    {
        List&lt;string[]&gt; allLineFields = new List&lt;string[]&gt;();

        try
        {
            using (TextReader sr = new StringReader(csv_file_path))
            using (TextFieldParser csvReader = new TextFieldParser(csv_file_path))
            {
                csvReader.Delimiters=new[] { "," };
                csvReader.HasFieldsEnclosedInQuotes = true;
                while (!csvReader.EndOfData)
                {

                    string[] fieldData = csvReader.ReadFields();
                    string pattern = "\"";
                    string replacement = "";
                    Regex rgx = new Regex(pattern);
                    //Making empty value as null
                    for (int i = 0; i &lt; fieldData.Length; i++)
                    {
                        //Remove quotation marks on Fields
                        fieldData[i] = Regex.Replace(fieldData[i], pattern, replacement);
                        if (fieldData[i] == "")
                        {
                            fieldData[i] = null;
                        }
                    }
                    //csvData.Rows.Add(fieldData);
                    allLineFields.Add(fieldData);
                }
            }
        }
        catch (Exception ex)
        {
        }
        return allLineFields;
    }
</code></pre>