note 94515 added to function.fgets

From: Date: Tue, 10 Nov 2009 02:19:22 +0000
Subject: note 94515 added to function.fgets
Groups: php.notes 
Request: Send a blank email to php-notes+get-162681@lists.php.net to get a copy of this message
This option posted above worked really good for me for a very large file: $filename = "../temp/file.txt"; $handle = @fopen($filename, "r"); //read from this line $ic = 2300000; //read to this line $ic_max = 2600000; // stops after this number of rows if ($handle) { while (!feof($handle) && ++$ic<=$ic_max) { $line = fgets($handle); $final_line = explode("|",$line); //echo "<br>".$final_line[0]. '|' .$final_line[1]. '|' .$final_line[2]; if(!mysql_query("INSERT INTO table (ID, name, comercial_name) VALUES ('','$final_line[0]', '$final_line[1]', '$final_line[2]')")) { fclose($handle); die($link->sql_error() . "<br>The connection to the DB fail. (populateTAble).<br>"); } } fclose($handle); } ---- Server IP: 69.147.83.197 Probable Submitter: 201.229.221.242 ---- Manual Page -- http://www.php.net/manual/en/function.fgets.php Edit -- https://master.php.net/note/edit/94515 Del: integrated -- https://master.php.net/note/delete/94515/integrated Del: useless -- https://master.php.net/note/delete/94515/useless Del: bad code -- https://master.php.net/note/delete/94515/bad+code Del: spam -- https://master.php.net/note/delete/94515/spam Del: non-english -- https://master.php.net/note/delete/94515/non-english Del: in docs -- https://master.php.net/note/delete/94515/in+docs Del: other reasons-- https://master.php.net/note/delete/94515 Reject -- https://master.php.net/note/reject/94515 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#162681) next »