I am trying to read a csv file using the following code. Its throwing an exception if there is double quotes (") in the data. I want to handle all the special chars while reading.
using (TextReader reader = new StreamReader("C:\\test\test.csv"))
{
using (CsvReader csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
csv.Read();
csv.ReadHeader();
while (csv.Read())
{
var result= csv[0].Split(';');
}
}
}
My CSV file: The csv.Read is failing line at line# 3
Name;Location;State;Country
Keka1;Lansing; MI; USA
Keka2;"Ohio"; OH; USA // Error at this line
Keka3;Lansing; MI; USA
I do not want to escape quotes, but want to include it. Please advice.