5.9. Parse a Delimited Text File
Problem
You need to parse the contents of a delimited text file.
Solution
Create and configure a new Microsoft.VisualBasic.FileIO.TextFieldParser object that references the file you need to parse. Loop through the file until the EndOfData property is True. Use the ReadFields method to return an array of strings representing one row of parsed data from the file.
How It Works
The TextFieldParser class can be found in the Microsoft.VisualBasic.FileIO namespace. You can either use one of its constructors to create an instance directly or use the Shared My.Computer. FileSystem.OpenTextFieldParser method to return an instance. Some of the more important properties and methods of this class are listed in Table 5-7
Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.