Created
July 30, 2013 15:08
-
-
Save theorigin/6113797 to your computer and use it in GitHub Desktop.
Parse CSV using Microsoft.VisualBasic.FileIO.TextFieldParser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using MyReader As New _ | |
Microsoft.VisualBasic.FileIO.TextFieldParser("C:\testfile.txt") | |
MyReader.TextFieldType = FileIO.FieldType.Delimited | |
MyReader.SetDelimiters(",") | |
Dim currentRow As String() | |
While Not MyReader.EndOfData | |
Try | |
currentRow = MyReader.ReadFields() | |
Dim currentField As String | |
For Each currentField In currentRow | |
MsgBox(currentField) | |
Next | |
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException | |
MsgBox("Line " & ex.Message & _ | |
"is not valid and will be skipped.") | |
End Try | |
End While | |
End Using |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment