Executive Summary:
Although you can use a TextStream object to open a plain-text file, it's not advantageous because you can only read the file from the beginning. However, you can use ADO, which enables you to use the Microsoft Jet OLE DB text driver to parse the contents of a delimited file, to read delimited files. The Jet OLE DB text driver uses the registry to determine the format of the delimited file. |
Reading delimited files is a common scripting task. For example, you might want a script to process a list of users and their email addresses that you exported to a delimited text file using the Microsoft Management Console (MMC) Active Directory Users and Computers snap-in.
Delimited files are plain-text files that often represent the contents of a database table. The data on each line in the file is separated by a delimiter (e.g., a comma or a tab). Figure 1 shows a sample delimited file in which the delimiter is a comma. This type of delimited file is known as a comma-separated values (CSV) file. The first line of the file, which is referred to as the header line, names the fields (columns) in the table. The subsequent lines contain the table's records (rows). In this example, the field names and record data are enclosed in double quotes (").
Of course, you can use the FileSystemObject's TextStream object to open plain-text files, but parsing the contents of delimited files presents some interesting problems. For example, you could open the file and use VBScript's Split function to split each line into fields, but doing so can present a problem if the line contains quoted data with an embedded delimiter. For example, consider the following comma-delimited address data:
"13100 Ellison Rd. NW","Albuquerque, NM","87114"
Now suppose you use the following line of VBScript code to parse the line: . . .

