Promote Your Blog

Friday, March 2, 2012

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


Dim currentRow As String()

While Not MyReader.EndOfData


currentRow = MyReader.ReadFields()

ir = ir + 1

Catch ex As Microsoft.VisualBasic.


MsgBox("Line " & ex.Message &

"is not valid and will be skipped.")

End Try

End While

End Using

No comments:

Post a Comment