Home All Groups Group Topic Archive Search About

File pointer to be positioned at the last occurance of a keyword

Author
11 Apr 2005 11:15 AM
kd
Hi All,

I have a .txt file, in which I have to look for the last occurance of a
keyword, and process contents of the file from that point onwards.

How can this be achieved? Can anybody guide me?

Thanks,
kd

Author
11 Apr 2005 11:53 AM
Crouchie1998
Is there a specific keyword or can it be any?

If one, its easy & if more then create a regex to handle it.

Crouchie1998
BA (HONS) MCP MCSE
Author
11 Apr 2005 12:06 PM
kd
Hi Crouchie,

It is a specific word that I am looking for. It would be great if you could
post a sample code here.

Thanks,
kd


Show quoteHide quote
"Crouchie1998" wrote:

> Is there a specific keyword or can it be any?
>
> If one, its easy & if more then create a regex to handle it.
>
> Crouchie1998
> BA (HONS) MCP MCSE
>
>
>
Author
11 Apr 2005 12:23 PM
Herfried K. Wagner [MVP]
"kd" <k*@discussions.microsoft.com> schrieb:
> I have a .txt file, in which I have to look for the last occurance of a
> keyword, and process contents of the file from that point onwards.

Reading a text file line-by-line or blockwise with a progress indicator
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=readfile&lang=en>

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
11 Apr 2005 1:03 PM
kd
Hi,

I don't think that, reading the text file, line by line and checking for the
keyword is a good idea, because, the file is large and the keyword occurs
several times in the file. I need to only process the data that occurs after
the last occurance of the keyword in the file.

Regards,
kd

Show quoteHide quote
"Herfried K. Wagner [MVP]" wrote:

> "kd" <k*@discussions.microsoft.com> schrieb:
> > I have a .txt file, in which I have to look for the last occurance of a
> > keyword, and process contents of the file from that point onwards.
>
> Reading a text file line-by-line or blockwise with a progress indicator
> <URL:http://dotnet.mvps.org/dotnet/faqs/?id=readfile&lang=en>
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://classicvb.org/petition/>
>
Author
11 Apr 2005 2:01 PM
kd
Hi Herfried,

Thanks for your reply.

Is there a work-around for this situation without having to read line-by-line?

Regards,
kd.

Show quoteHide quote
"kd" wrote:

> Hi,
>
> I don't think that, reading the text file, line by line and checking for the
> keyword is a good idea, because, the file is large and the keyword occurs
> several times in the file. I need to only process the data that occurs after
> the last occurance of the keyword in the file.
>
> Regards,
> kd
>
> "Herfried K. Wagner [MVP]" wrote:
>
> > "kd" <k*@discussions.microsoft.com> schrieb:
> > > I have a .txt file, in which I have to look for the last occurance of a
> > > keyword, and process contents of the file from that point onwards.
> >
> > Reading a text file line-by-line or blockwise with a progress indicator
> > <URL:http://dotnet.mvps.org/dotnet/faqs/?id=readfile&lang=en>
> >
> > --
> >  M S   Herfried K. Wagner
> > M V P  <URL:http://dotnet.mvps.org/>
> >  V B   <URL:http://classicvb.org/petition/>
> >
Author
12 Apr 2005 7:23 AM
kd
Hi Herfried,

The only way to go about this, is to read the file line by line and to the
processing?
Please reply.

Thanks,
kd

Show quoteHide quote
"Herfried K. Wagner [MVP]" wrote:

> "kd" <k*@discussions.microsoft.com> schrieb:
> > I have a .txt file, in which I have to look for the last occurance of a
> > keyword, and process contents of the file from that point onwards.
>
> Reading a text file line-by-line or blockwise with a progress indicator
> <URL:http://dotnet.mvps.org/dotnet/faqs/?id=readfile&lang=en>
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://classicvb.org/petition/>
>
Author
12 Apr 2005 7:48 AM
Cor Ligthert
kd,

Read the rows in using the readline and set the lines in an arraylist

Process that arraylist backwards using the
\\\
For i as integer = arraylist.length - 1 step -1
see if it exist in the lines using the indexof or the instr
Next
///
I hope this helps,

Cor
Author
12 Apr 2005 12:36 PM
kd
Hi Cor,

Thanks for the reply.

I do however have a question. Would Arraylist be able to store a huge file?
What is maximum capacity of Arraylist?

Regards,
kd.

Show quoteHide quote
"Cor Ligthert" wrote:

> kd,
>
> Read the rows in using the readline and set the lines in an arraylist
>
> Process that arraylist backwards using the
> \\\
> For i as integer = arraylist.length - 1 step -1
> see if it exist in the lines using the indexof or the instr
> Next
> ///
> I hope this helps,
>
> Cor
>
>
>
Author
12 Apr 2005 1:21 PM
Cor Ligthert
KD,

I think that you should try it, however it is of course dependable from the
memory that is available

Cor