Ad Code

Responsive Advertisement

How To Count Number of Records In A .csv File

You are right!!! Just put a counter inside the while loop reading .csv file row by row i.e.

Dim ir As Integer = 0

Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(fn)

MyReader.TextFieldType = FileIO.FieldType.Delimited

MyReader.SetDelimiters(",")

Dim currentRow As String()

While Not MyReader.EndOfData

Try

currentRow = MyReader.ReadFields()

ir = ir + 1

Catch ex As Microsoft.VisualBasic.

FileIO.MalformedLineException

MsgBox("Line " & ex.Message &

"is not valid and will be skipped.")

End Try

End While

End Using

Post a Comment

0 Comments