logo       

Opening large text files on Windows: msg#03628

php.general

Subject: Opening large text files on Windows

Good afternoon all.

I have a problem with opening a text file in PHP.

The file is test.txt a comma separated file with 62,000 lines (4Mb) of data.
I have extended the execution time to 200 seconds to allow time to read the
file. The code I am using is below.

set_time_limit(200);
$datafile = fopen ("text.txt", "r");
while (!feof ($datafile)) {
$array = fgets($datafile, 1000000);
if (trim($array)) {
$count = count(explode($Seper, $array));
} // end if $array
} // end while
fclose ($datafile);
echo $count;

My problem is that the file never finishes.
The php.exe (running on windows 2000) in the task manager keeps running for
over 20 mins (then I kill it) and explorer keeps waiting for a reply.

Is there a better way to read this file in to check ??

> Richard
>
This message is confidential to Sunrise Medical. If you are not the intended
recipient, do not use or distribute this message; and please notify the
sender by return of e-mail.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise