CSV Helper, Read File With Double Quotes in Field Data

Viewed 2475

I need some help ion CSV parsing with CSV Helper in C#

my example file is

"SKU","Title","URL","BP","SP","NumberOf","Wid1","Wid2","Wid3"
"Big Corp","CRM updates","test","0","0","0","0","0","0"
"Big Corp 1","CRM "test" updates","test","0","0","0","0","0","0"

my configuration is

using (TextReader reader = File.OpenText(location))
            {
                using (var csv = new CsvReader(reader, System.Globalization.CultureInfo.CurrentCulture))
                {
                    csv.Configuration.RegisterClassMap<ProductMap>();
                    List<Product> records = csv.GetRecords<Product>().ToList();
                    return records;
                }
            }

I am getting error in last row where 1 field has double quote in it. What settings I need to do If I want to escape/remove the double quotes?

I have also tried to replace the double quotes in mapping file but double quotes are being show in wrong place. double quotes are on "test" word but in the data they are shows on "updates" word.

enter image description here

and then

enter image description here

I can replace double quote with an empty string in the mapping file but is there any other solution?

0 Answers
Related