View Full Version : Read records from file and delete them?

02-03-2003, 01:17 PM
Is there a way that I can read the first number of records of a file, say 200, and then delete those 200 records? It is a large file, so I would prefer to minimize the amount of file rewriting I do.

02-04-2003, 04:23 PM
Hi, you can open a file for reading and writing with


and traverse the file with fseek() etc, but the best you will be able to do (AFAIK) is overwrite the first $x lines with '' , you will still have say, 200 empty lines at the start of your file.

unless your file is repressivly large ... and if it is it should not be ;) - then reading the file and rewriting really is the best solution, & as long as you are not echoing the data to screen or anything should be fast enough.

on *NIX there are the direct i/o functions, dio_truncate() will truncate the file to $x bytes, though from what 'end' I can't say as I have yet to use them.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum