How do I read a text file into an array except the first five lines?

Re: Readall command by James

James
Tue Nov 29 12:05:57 CST 2005

"indyboy" <dontread@indy.rr.com> wrote in message
news:1133284088.628026.296590@g47g2000cwa.googlegroups.com...
> How do I read a text file into an array except the first five lines?

You could use the 'skipline' method to move down 5 lines and then use the
'split' function to split the file into an array.

SkipLine Method:
http://msdn.microsoft.com/library/en-us/script56/html/wsmthskipline.asp

Split Function:
http://msdn.microsoft.com/library/en-us/script56/html/vsfctsplit.asp

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim oFSO, oInputFile, aLines, i
Set oFSO = CreateObject("Scripting.FileSystemObject")

Set oInputFile = oFSO.OpenTextFile("myfile.txt", 1)

For i = 1 to 5
oInputFile.SkipLine
Next

aLines = Split(oInputFile.ReadAll(), vbCrLf)
oInputFile.Close
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Re: Readall command by \

\
Tue Nov 29 12:14:33 CST 2005

> How do I read a text file into an array except the first five lines?

As usual, there is more than one way to do this. You can read the whole thing
and edit out the five lines in your script, or you can move the file pointer
past the first five lines before reading the remaining text. I prefer the second
method:

'------------------------------
Set fso=CreateObject("Scripting.FileSystemObject")
Set reader=fso.OpenTextFile("d:\filename.ext",1)
Dim data

for n=1 to 5
if reader.AtEndOfStream then exit for
reader.skipLine
next

if not reader.AtEndOfStream then data=reader.readAll
dataArray=split(data,vbCRLF)
'-------------------------------
--
Crash