Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Read a comma delimited file in vbs and ignoring the last line

$
0
0

I got a text file like this.

 

BeginWord, Word1, Word2, Word3, Word4, Word5, Word6

Word, Word1, Word2, Word3, Word4, Word5, Word6

Word, Word1, Word2, Word3, Word4, Word5, Word6

End

I want to read the whole file and only get the first word and the last word of each line, but when my code reaches the last line I get an error (OutofBound??) due to "End" in an Array of 0-6.

My code is not finished but you kind of get what I mean.

Const ForReading = 1
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\Read.txt", ForReading)

 

Do Until objTextFile.AtEndOfStream
    strNextLine = objTextFile.Readline
    arrServiceList = Split(strNextLine , ",")
 
 
    output = output & "Process name: " & arrServiceList(0) & "QUE Length: " & arrServiceList(6) & vbCrLf
   
 Wscript.Echo output
   
Loop

 


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>