M
mkarja
Hi,
I'm trying to figure out how to read some range of rows from a
file.
Is it possible to search the file with some criteria and then
when the search string is found read 3 rows before and after
that row from where the search string was found ?
Of course the row where the string was found should also be read.
I have a log file in txt format. I need to read the file if
there's any errors. There's two lines that has error information
if something goes wrong. I need to get the errors and the command
that caused the error which is about three rows above the first
error line. I have to use the error as a search string because
the command changes everytime so I can't use the command as a
search string.
The error lines are as follows:
/*** SYNTAX ERROR ***/
/*** INVALID PARAMETER NAME ***/
I'm using /*** as a search string.
I could use seekg if I just needed to read the file forward from
the point where the search string was found, but I can't figure
how I could do what I'm trying to do here.
I hope you understand what I'm trying to do here. If not, I'll
try to explain more.
I'm trying to figure out how to read some range of rows from a
file.
Is it possible to search the file with some criteria and then
when the search string is found read 3 rows before and after
that row from where the search string was found ?
Of course the row where the string was found should also be read.
I have a log file in txt format. I need to read the file if
there's any errors. There's two lines that has error information
if something goes wrong. I need to get the errors and the command
that caused the error which is about three rows above the first
error line. I have to use the error as a search string because
the command changes everytime so I can't use the command as a
search string.
The error lines are as follows:
/*** SYNTAX ERROR ***/
/*** INVALID PARAMETER NAME ***/
I'm using /*** as a search string.
I could use seekg if I just needed to read the file forward from
the point where the search string was found, but I can't figure
how I could do what I'm trying to do here.
I hope you understand what I'm trying to do here. If not, I'll
try to explain more.