Deleting Records in Text Files 
Author Message
 Deleting Records in Text Files

Dear Group,

I have a text file that I have converted from the older MBF file.  I would
like to be able to delete the last two lines of the file.

I understand that I can recreate the text file into a new file and just
leave out the data that I dont want.  This seams like a workaround and not a
solution.

I also understand that I can erase the characters in the records, but I
would still be left with stuff on the record.  Meaning the EOF function
would not trigger the end of file.

Any help would be appreciatted.

Kindest Regards,
Matt Stecher



Fri, 10 Jan 2003 03:00:00 GMT  
 Deleting Records in Text Files
Because the length of the records in a text file is variable, and
because the file is generally processed as a stream, the standard method
for deleting data is to make a new copy of the file consisting of the
correct stream of data.  This is scarcely a workaround.

However, given your particular requirements, you can probably achieve
what you require by reading the file backwards as binary (perhaps in 1k
increments), finding the eof, identifying the third to last cr/lf pair
(possibly the delimiter is just cr or lf, but in most files they occur
as a pair), and writing a single byte - an eof (x1a) - immediately
thereafter.  

Quote:

> Dear Group,

> I have a text file that I have converted from the older MBF file.  I would
> like to be able to delete the last two lines of the file.

> I understand that I can recreate the text file into a new file and just
> leave out the data that I dont want.  This seams like a workaround and not a
> solution.

> I also understand that I can erase the characters in the records, but I
> would still be left with stuff on the record.  Meaning the EOF function
> would not trigger the end of file.

> Any help would be appreciatted.

> Kindest Regards,
> Matt Stecher



Fri, 10 Jan 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Deleted records when text file is linked as table (#deleted)

2. VB5: Deleting records using a text Dbase file...

3. How to Delete a record(or records) inside an open file

4. Text file records comparaison against a Master text file

5. Text file records comparaison against a Master text file

6. Deleting text from a range in a text file

7. VB5: Deleting records from a (text) data base?

8. Delete record in ASCII file, I really can't figure it out

9. cannot delete record from external table (.dbf file)..

10. How to delete Random file record!

11. Delete record in ASCII file, I really can't figure it out

12. Deleting Records in sequencial file

 

 
Powered by phpBB® Forum Software