|
Posted by Daemon on 12/30/05 10:09
Justin Koivisto wrote:
> enterthe@walla.com wrote:
>
>>I understand that there are many ways to jump directly to a line when
>>parsing a text file. However, I don't know which is the fastest.
>>
>>I am parsing files over 100 megs in size, with tens of thousands of
>>lines. Getting to some lines is causing my scripts to time out due to
>>the time it's taking to get to certain lines.
>
>
> What that amount of data, don't you think it's time to move into a
> database instead?
>
set_time_limit(0);
Will solve your 'time outs'. A script is issued about 30 seconds I
believe by default. Now, yes, there are many ways to get 'lines' in a
file, one of the best ways to do this I would believe is to create a
"while" loop for fgets(); that way you can use a statment that counts
the number of lines, till the requested line appears. One of the best
ways is to parse roughly 2048 or 4092 bytes of data, I think, for every
CR/LF/CRLF depending on your data and environment.
There are otherways, to determin the line within php functions I
believe, but youll just have to review the file functions in the manual
at php.net
~ Daemon
Navigation:
[Reply to this message]
|