title: Skip the first line of the CSV file (Headers) Visual Basic
body: <p>Like many on here, I am new to programming and mainly focus on web development. I have written a program cobbled together from help on here that works perfectly. I take a CSV file and inject it into an SQL database. I am getting a "MalformedLineException" line exception on the last line of the CSV file and believe it is because the header line is not being skipped. </p>
  
  <p>Would love some help on working out how to skip the first line from my code below:</p>
  
  <pre><code>        Private Sub subProcessFile(ByVal strFileName As String)
      'This is the file location for the CSV File
      Using TextFileReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(strFileName)
  
          'removing the delimiter
          TextFileReader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
          TextFileReader.SetDelimiters(",")
          ProgressBar1.Value = 0
          Application.DoEvents()
          'variables
          Dim TextFileTable As DataTable = Nothing
          Dim Column As DataColumn
          Dim Row As DataRow
          Dim UpperBound As Int32
          Dim ColumnCount As Int32
          Dim CurrentRow As String()
  
  
          'Loop To read in data from CSV
          While Not TextFileReader.EndOfData
              Try
  
                  CurrentRow = TextFileReader.ReadFields()
  
                  If Not CurrentRow Is Nothing Then
                      ''# Check if DataTable has been created
                      If TextFileTable Is Nothing Then
                          TextFileTable = New DataTable("TextFileTable")
                          ''# Get number of columns
                          UpperBound = CurrentRow.GetUpperBound(0)
                          ''# Create new DataTable
                          For ColumnCount = 0 To UpperBound
                              Column = New DataColumn()
                              Column.DataType = System.Type.GetType("System.String")
                              Column.ColumnName = "Column" &amp; ColumnCount
                              Column.Caption = "Column" &amp; ColumnCount
                              Column.ReadOnly = True
                              Column.Unique = False
                              TextFileTable.Columns.Add(Column)
  
                              ProgressBar1.Value = 25
                              Application.DoEvents()
                          Next
  
                          clsDeletePipeLineData.main()
  
                      End If
  
                      Row = TextFileTable.NewRow
                      'Dim Rownum As Double = Row
                      'If Rownum &gt;= 1715 Then
                      '    MsgBox(Row)
                      'End If
                      For ColumnCount = 0 To UpperBound
                          Row("Column" &amp; ColumnCount) = CurrentRow(ColumnCount).ToString
                      Next
                      TextFileTable.Rows.Add(Row)
                      clsInsertPipeLineData.main(CurrentRow(0).ToString, CurrentRow(1).ToString, CurrentRow(2).ToString, CurrentRow(3).ToString, CurrentRow(4).ToString, CurrentRow(5).ToString, CurrentRow(6).ToString, CurrentRow(7).ToString, CurrentRow(9).ToString)
                      ProgressBar1.Value = 50
                      Application.DoEvents()
                  End If
  
              Catch ex As _
              Microsoft.VisualBasic.FileIO.MalformedLineException
                  MsgBox("Line " &amp; ex.Message &amp;
                  "is not valid and will be skipped.")
  
              End Try
          End While
          ProgressBar1.Value = 100
          Application.DoEvents()
          clsMailConfirmation.main()
          TextFileReader.Dispose()
          MessageBox.Show("The process has been completed successfully")
  
      End Using
  </code></pre>