CSV:意外的结转列值

时间:2017-10-06 00:50:18

标签: c# csv

解析CSV时我遇到了一个奇怪的问题,一个空列x的行正在从列x的前一行返回一个值。代码如下。

string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties='text;HDR=Yes;FMT=Delimited';";

using (OleDbConnection cn = new OleDbConnection(connectionString)
{
  cn.Open();
  using (OleDbCommand cmd = cn.CreateCommand())
  {
     cmd.CommandText = "SELECT * FROM [" + fileName + ".csv]";
     cmd.CommandType = CommandType.Text;
     using (OleDbDataReader reader =  cmd.ExecuteReader(CommandBehavior.CloseConnection))
     {
        foreach (DbDataRecord record in reader)
        {
           string value = !record.IsDBNull(9) ? record.GetValue(9).ToString() : string.Empty;

etc

0 个答案:

没有答案