title: How to convert csv file content to DataTable?
body: <p>I convert CSV file to DataTable using following code. It is working fine but sometimes it adds invalid character between the string.</p>
  
  <pre><code>Private Shared Function convertToDT(filePath As String) As DataTable
      Dim detailDataTable As New DataTable()
      Using csvReader As New TextFieldParser(filePath)
          csvReader.SetDelimiters(New String() {","})
          csvReader.HasFieldsEnclosedInQuotes = True
          Dim colFields As String() = csvReader.ReadFields()
  
          For Each column As String In colFields
              Dim datecolumn As New DataColumn(column.ToLowerInvariant)
              datecolumn.AllowDBNull = True
              detailDataTable.Columns.Add(datecolumn)
          Next
  
          While Not csvReader.EndOfData
              Dim rowData As String() = csvReader.ReadFields  //sometimes rowData convert invalid name
              For i As Integer = 0 To rowData.Length - 1
                  //perform operation
              Next
              If rowData IsNot Nothing AndAlso rowData(0) IsNot Nothing Then
                  If Not (rowData(0).StartsWith("#") Or String.IsNullOrEmpty(rowData(0))) Then
                      detailDataTable.Rows.Add(rowData)
                  End If
              End If
          End While
      End Using
      Return detailDataTable
  End Function
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/AIOKZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AIOKZ.png" alt="enter image description here"></a>
  Sometime it add invalid name. Can anybody please suggest</p>