Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract every 5th row on text file

Status
Not open for further replies.

lovettj

Programmer
May 22, 2007
10
US
I need to create a script that extracts every 5th row in a text file using vbscript. If anyone could please help me it will be very appreciative.

Thanks in advance.
 
I know how to open a file a write a file using the filesystem object. I need to know how to write every 5th row of the text file.
 
Have a look at the Mod operator.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
As PHV states:

Counter = 0
Do
Counter = Counter + 1
InputData = InStream.ReadLine
If Counter Mod 5 = 0 Then OutStream.WriteLine InputData
Loop Until InStream.AtEndOfStream

Swi
 
You are correct. I get in the habit of using a counter because I normally display the progress of the program when running.

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top