我想解析一个大小约为1GB的制表符分隔文件。读取和分析非常大的文件的内容
当我运行该脚本,我得到:
Fatal error: Allowed memory size of 1895825408 bytes exhausted (tried to allocate 1029206974 bytes) ...
我此刻的脚本就是:
$file = file_get_contents('allCountries.txt') ;
$file = str_replace(array("\r\n", "\t"), array("[NEW*LINE]", "[tAbul*Ator]"), $file) ;
我已经设置php.ini中的内存限制为-1,然后给我:
Fatal error: Out of memory (allocated 1029963776) (tried to allocate 1029206974 bytes)
反正是有部分打开该文件,然后使更少的内存用完移动到下一部分一次?
为什么不逐行处理文件? – 2013-02-13 08:04:26