File Processing Programming Question

THT

THT

Associate
Joined
10 Mar 2004
Posts
998
Heres what I need to do:

I have a text file with multiple lines which is constantly updating.

I want to read the file and delete the row i process without losing any new data that has been added since I first opened it.


For example:

1) File Has 4 rows
2) Open file read first row
3) Another row is added to the file

I now need to delete line 1, without losing line 5


What the best way to do this - not looking for actual code - simply method
 
what languages do you know?

It can be quite hard to read a file whilst allowing writing to it at the same time. you can do it in C and C++ but I think that most of the .net File.io stuff locks the file. why are you deleting the entries from the file? just leave them there and keep processing. in this way you will only need read access to the file so it'll be easier to leave it open and allow the other app to write to it.

tail -f inputfile.txt >> outputfile.txt is your dos command of the day ;)

HT
 
hi HT,

Long time no speak (we spoke a long time ago here when I had a differen username)

Yeah I can Do C, C++ - I try to avoid .net cos i just dont like it!

The reason I dont want to leave the entries there, is next time i open the program, i dont want to have to process all those again.
I could clear the file, but then id lose any outstanding entries.

Any ideas?

Thanks
 
the problem is going to be deleting the entry. if you want to delete the entry you need a write lock on the file. if youplace a write log on the file the 'other process' can't write the next entry in it because you have a lock on it!

I'd either keep track of the log entries processes somewhere else or use the command I offered in the last post as a method for getting a 2nd copy of the file!

How were you thinking of doing it?

HT
 
Im liking the tail idea

i guess playing around with that could work

im not sure :S

thanks for the help HT

ill look into it further
 
Back
Top Bottom