Re: getting one line from file

From: Date: Thu, 31 Aug 2000 15:39:48 +0000
Subject: Re: getting one line from file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-14630@lists.php.net to get a copy of this message
I have a similar problem, except my file is over 100 megs and I'm not sure what I'm looking for...so I have a curiosity question...I'm assuming that the file is like a delimited text file..if so it has fields and records... the number your looking for, I assume it always appears in a particular/same field,...isn't it possible to sort the file based on a particular field and only search the sorted field for your info... ken Michael Packer wrote: > > The text file i'm search is 9,859,103 bytes (today, it will be a bit larger > tomorrow) > (30,072 lines) > > generally the line i'll be looking for is in the first 9,000 or so lines... > the web server that i'm doing this on is dual p3 500 with 512mb > > i'm only looking for the one line that contains a specific number (and i > know for a > fact that the number will not (ever) be duplicated in another line. > > pac > > > > > how big is the file your reading? > > > > How beefy is your webserver? > > > > Is this file one line? if so why grep? thats overhead you dont need? > > just open the file, and put the whole thing into any array, then access > > what you need. It will probally be quicker then doing a system call, and > > using grep tooo, , all that causes overhead. on the other hand if this > > file is a big one, that will wlos you down to. > > > > On Thu, 31 Aug 2000, Michael Packer wrote: > > > > > > > > > pac@stingrayboats.com ("Michael Packer") writes: > > > > > > > >> I'm just learning PHP and have a question....in perl I used > > to do this: > > > >> > > > >> $info = grep "676" > > > >> /tmp/somefile.txt; > > > >> (i know there was only one line in the file with that number, > > > >>thats why it's not @info) > > > >> > > > >> i need to only get one line out of this file that is very large > > > >>(which is why i don't want to open it read through the file > > until i find > > > >>the correct line)... > > > > > > > > try this: :-) > > > > > > > > $info = grep "676" /tmp/somefile.txt; > > > > > > > > > well i tried this..it works, but damn it take a performance > > hit...do system > > > calls rereally effect PHP that much? > > > > > > instead of instantly loading, it now takes about 2-3 seconds > > > > > > any other ideas? > > > > > > thanks! > > > pac > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > For additional commands, e-mail: php-general-help@lists.php.net > > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#14630) next »