I am using OLEDB to parse CSV file into DataTable. It is working fine but it creates an issue when some value in CSV contains double quote("). OLEDB skips the value of the of the next remaining columns in that row.
For example, I have following values in CSV file. Here value of Col2 in second row contain the double quote(").
When I parse the CSV to DataTable then DataTable contains the following values. Here the value of col3 and col4 in blank in the second row.
I am using following connection string
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties='text;HDR=Yes;IMEX=1;ColNameHeader=True;CharacterSet=65001;FMT=Delimited(,)'"
And query is
"select * from [" + fileName + "]"
Here is the full code
string connStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties='text;HDR=Yes;IMEX=1;ColNameHeader=True;CharacterSet=65001;FMT=Delimited(,)'";
using (OleDbConnection conn = new OleDbConnection(connStr))
{
conn.Open();
table = new DataTable();
var dataAdapter = new OleDbDataAdapter("select * from [" + fileName + "]", conn);
dataAdapter.Fill(table);
}
How can I ignore double quote(") from value?
Note: I am downloading the file from the third party directly use that this CSV for parsing.