473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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
Nov 21 '05 #1
9 1082
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
Nov 21 '05 #2
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
"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

Nov 21 '05 #3
"kd" <kd@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/>
Nov 21 '05 #4
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

"Herfried K. Wagner [MVP]" wrote:
"kd" <kd@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/>

Nov 21 '05 #5
kd
Hi Herfried,

Thanks for your reply.

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

Regards,
kd.

"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" <kd@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/>

Nov 21 '05 #6
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

"Herfried K. Wagner [MVP]" wrote:
"kd" <kd@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/>

Nov 21 '05 #7
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
Nov 21 '05 #8
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.

"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

Nov 21 '05 #9
KD,

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

Cor
Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Fadi Komati | last post by:
Dear All, I need your help concerning the following. I am openeing a log file for processing (I need to look for certain activities) obviously i keep reading until the end of file. What i...
11
by: Abhishek | last post by:
I have a problem transfering files using sockets from pocket pc(.net compact c#) to desktop(not using .net just mfc and sockets 2 API). The socket communication is not a issue and I am able to...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
13
by: athiane | last post by:
I want a way to parse out all function names that appear in a couple of C files. When the parsing logic finds a function name in a file, it should print out the Function name, line number and file...
6
by: tomtown.net | last post by:
Hello I'm trying to get a single line removed from a text file using a search pattern (pretty simple: if line contains "NODE1") -> remove line). To achieve this I's like to operate with only the...
75
by: ume$h | last post by:
/* I wrote the following program to calculate no. of 'a' in the file c:/1.txt but it fails to give appropriate result. What is wrong with it? */ #include"stdio.h" int main(void) { FILE *f;...
6
by: worlman385 | last post by:
For pointer and non-pointer initialization of an object like MyCar mycar; MyCar* mycar = new MyCar(); I heard from other people saying if object i create must live outside scape, then I use...
26
by: aruna.mysore | last post by:
Hi all, I have a specific problem passing a function pointer array as a parameter to a function. I am trying to use a function which takes a function pointer array as an argument. I am too sure...
7
by: mohi | last post by:
hello everyone, i have a program where i write a structure of 1020B to a file a number of times and in the next run of the program i have to again write those structures but by taking some count...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.