How to skip a few lines while reading from a text file?
-
i m currently working on a program which is able to read a text file. however, i have encountered this problem while extracting information from the text. first i have to reach a keyword found in the text (which i have successfully implemented), then i have to skip a few lines after the keyword to extract the useful information. i have no idea on how to skip the lines while the program is reading the information from the file. i think it is not wise to load everything into the program, which takes up memory, and discard. could anyone suggest on how to ignore the useless information? Thanks. Esther
-
i m currently working on a program which is able to read a text file. however, i have encountered this problem while extracting information from the text. first i have to reach a keyword found in the text (which i have successfully implemented), then i have to skip a few lines after the keyword to extract the useful information. i have no idea on how to skip the lines while the program is reading the information from the file. i think it is not wise to load everything into the program, which takes up memory, and discard. could anyone suggest on how to ignore the useless information? Thanks. Esther
Simple. Just read the line, or lines, you want to skip and don't do anything with them. You'll probably want to read the exact number of lines you want to skip inside a for/next loop.
Dim strDiscard as String
For x = 1 to n
strDiscard = ReadLine(filepointer) ' or whatever your using to read a line from the file
Next -
Simple. Just read the line, or lines, you want to skip and don't do anything with them. You'll probably want to read the exact number of lines you want to skip inside a for/next loop.
Dim strDiscard as String
For x = 1 to n
strDiscard = ReadLine(filepointer) ' or whatever your using to read a line from the file
Next