I need to parse a utf8 encoded csv. After conversion i just saw that the problem is with the BOM () character at the beginging. I cannot create a csv avoiding the BOM with utf8 encoding as i need to parse it even if it is utf8 encoded.
Any one please tell me how can i remove the BOM () character from a csv using c#.net..
Update : I have added my code to read the csv headers since im getting the BOM at the beginning of the file.
string CSVConnectionString = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + ConfigurationSettings.AppSettings["CSVFolder"].ToString() + ";Extensions=asc,csv,tab,txt;Persist Security Info=False;";
using (OdbcConnection Connection = new OdbcConnection(CSVConnectionString))
{
List<string> CSVHeaders = new List<string>();
string SelectQuery = string.Format(@"SELECT TOP 1 * FROM [{0}]", CSVFileName);
OdbcCommand Command = new OdbcCommand(SelectQuery, Connection);
Connection.Open();
OdbcDataReader Reader = Command.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
int ColumnCount = Reader.FieldCount;
for (int column = 0; column < ColumnCount; column++)
{
CSVHeaders.Add(Reader.GetName(column));
}
return CSVHeaders;
}