shadiadiph Posted May 14, 2010 Share Posted May 14, 2010 is there any known quick way to find out the number of the last row of an csv file apart from opening it on your computer? Link to comment https://forums.phpfreaks.com/topic/201723-finding-the-number-of-the-last-row-in-a-csv-file/ Share on other sites More sharing options...
teamatomic Posted May 14, 2010 Share Posted May 14, 2010 No, but its only one line of code. $num_lines = count(file($file)); HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/201723-finding-the-number-of-the-last-row-in-a-csv-file/#findComment-1058244 Share on other sites More sharing options...
shadiadiph Posted May 15, 2010 Author Share Posted May 15, 2010 works fine on small files but on 127mb file it returns Fatal error: Allowed memory size of 262144000 bytes exhausted (tried to allocate 129761280 bytes) in /home/mysitel/publics_html/geoip/cityblockstest.php on line 144 using fgets would take too long i think Link to comment https://forums.phpfreaks.com/topic/201723-finding-the-number-of-the-last-row-in-a-csv-file/#findComment-1058583 Share on other sites More sharing options...
shadiadiph Posted May 15, 2010 Author Share Posted May 15, 2010 thanks for that it works but actually fgets with $lines=0; the $lines++ if the while loop works just as well on a big file. Link to comment https://forums.phpfreaks.com/topic/201723-finding-the-number-of-the-last-row-in-a-csv-file/#findComment-1058590 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.