Re: [PHP] How to jump to line number in large file

2008-04-05 Thread Robert Cummings
On Sat, 2008-04-05 at 16:19 -0700, Jim Lucas wrote: > Robert Cummings wrote: > >> > >> - Taking away the unnecessary fseek() made the script execute in 63 seconds > >> - Using a buffer system, (reading in 1Mb of the text file at a time and > >> then > >> looping through the string in memory) made

Re: [PHP] How to jump to line number in large file

2008-04-05 Thread Jim Lucas
Robert Cummings wrote: On Sat, 2008-04-05 at 19:09 +0100, Steve McGill wrote: "Richard Heyes" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Thanks for the heads up on fgetc() incrementing by one. I hadn't actually tested that code yet, I was using the original fseek($handle,$pos).

Re: [PHP] How to jump to line number in large file

2008-04-05 Thread Steve McGill
So the only variation on a theme that I didn't test is the one that performs the best by an order of magnitude... nice. Many thanks for your time everyone. "Robert Cummings" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > On Sat, 2008-04-05 at 19:09 +0100, Steve McGill wrote: >>

Re: [PHP] How to jump to line number in large file

2008-04-05 Thread Robert Cummings
On Sat, 2008-04-05 at 19:09 +0100, Steve McGill wrote: > "Richard Heyes" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> Thanks for the heads up on fgetc() incrementing by one. I hadn't actually > >> tested that code yet, I was using the original fseek($handle,$pos). > >> > >>

Re: [PHP] How to jump to line number in large file

2008-04-05 Thread Steve McGill
"Richard Heyes" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> Thanks for the heads up on fgetc() incrementing by one. I hadn't actually >> tested that code yet, I was using the original fseek($handle,$pos). >> >> strpos would be ideal but it needs to work on a string and not a fi

Re: [PHP] How to jump to line number in large file

2008-04-05 Thread Richard Heyes
Thanks for the heads up on fgetc() incrementing by one. I hadn't actually tested that code yet, I was using the original fseek($handle,$pos). strpos would be ideal but it needs to work on a string and not a file - I don't want to load a 100Mb file into memory if I don't have to. Perhaps I shou

Re: [PHP] How to jump to line number in large file

2008-04-05 Thread Steve McGill
Thanks for the heads up on fgetc() incrementing by one. I hadn't actually tested that code yet, I was using the original fseek($handle,$pos). strpos would be ideal but it needs to work on a string and not a file - I don't want to load a 100Mb file into memory if I don't have to. Perhaps I shoul

Re: [PHP] How to jump to line number in large file

2008-04-04 Thread Greg Bowser
fseek($handle, 1, SEEK_CUR); // or fseek($handle, $pos) $t = fgetc($handle); This probably won't help you, but given a quick glance, it looks like you're incrementing the file pointer by 2 positions on each iteration of your while loop. The fgetc() function returns the character at the