title: Delete rows on csv file in c# when the row does not start with a number
body: <p>After upload file this <strong>c-sharp</strong> code does convert an <strong>Excel file</strong> to <strong>CSV</strong> format saving with column separated for <strong><code>|</code></strong>.</p>
  
  <p>But when on the column <strong>"Annotations"</strong> of the Excel file has been entered <em>break line</em>, the output on csv format is wrong, because is adding the new rows for each <em>line break</em>, please see image below.</p>
  
  <p><a href="https://i.stack.imgur.com/hf2iS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hf2iS.png" alt="enter image description here"></a></p>
  
  <p>I need delete this row, because row does not start with a number ( <strong>column N</strong> ) or alternatively in the file Excel ( column <strong>Annotations</strong> ) replace the <em>break line</em>.</p>
  
  <p>I have tried this <em>replace code</em> without success:</p>
  
  <pre><code>csvData += result.Tables[ind].Rows[row_no][i].ToString().Replace("\r\n", "\n") + "|";
  </code></pre>
  
  <p>How to do resolve this ?</p>
  
  <p>Thank you in advance for any help.</p>
  
  <p>My code below.</p>
  
  <pre><code>FileUploadControl.SaveAs(Server.MapPath("/public/") + filename);
  FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read);
  
  Excel.IExcelDataReader excelReader = Excel.ExcelReaderFactory.CreateBinaryReader(stream);
  DataSet result = excelReader.AsDataSet();
  excelReader.Close();
  result.Tables[0].TableName.ToString();
  string csvData = "";
  int row_no = 0;
  int ind = 0;
  
  while (row_no &lt; result.Tables[ind].Rows.Count)
  {
      for (int i = 0; i &lt; result.Tables[ind].Columns.Count; i++)
      {
          csvData += result.Tables[ind].Rows[row_no][i].ToString() + "|";
      }
  
      row_no++;
      csvData += "\n";
  }
  
  output = System.Web.HttpContext.Current.Server.MapPath("/public/target_" + DateTime.Now.AddDays(-1).ToString("dd-MM-yyyy") + ".csv");                       
  StreamWriter csv = new StreamWriter(@output, false);
  csv.Write(csvData);
  csv.Close();
  csv.Dispose();
  </code></pre>
  
  <p><strong>#Edit 02</strong></p>
  
  <pre><code>while (row_no &lt; result.Tables[ind].Rows.Count)
  {
      for (int i = 0; i &lt; result.Tables[ind].Columns.Count; i++)
      {
          string text = result.Tables[ind].Rows[row_no][i].ToString();
          csvData += text.Replace("\r\n", " ") + "|";
      }
  
      row_no++;
      csvData += "\n";
  }
  </code></pre>
  
  <p><strong>#Edit 01</strong></p>
  
  <pre><code>while (row_no &lt; result.Tables[ind].Rows.Count)
  {
      for (int i = 0; i &lt; result.Tables[ind].Columns.Count; i++)
      {
          csvData += result.Tables[ind].Rows[row_no][i].ToString() + "|";
          string text = result.Tables[ind].Rows[row_no][i].ToString();
          csvData += text.Replace("\r\n", " ") + "|";
      }
  
      row_no++;
      csvData += "\n";
  }
  </code></pre>