Pages

10/08/2007

VBS::Parsing CSV


This is a great ongoing series:
Hey Scripting Guy!


Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Scripts\Test.txt", ForReading)

Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
arrFields = Split(strLine, ",")

If InStr(arrFields(1), "Everyone") Then
strContents = strContents & arrFields(5) & vbCrlf
End If
Loop

objFile.Close

Set objFile = objFSO.CreateTextFile("C:\Scripts\Everyone.txt")
objFile.Write strContents

objFile.Close

No comments: