gpt4 book ai didi

php - 读取并解析超大文件的内容

转载 作者:可可西里 更新时间:2023-11-01 12:30:22 24 4
gpt4 key购买 nike

<分区>

我正在尝试解析一个大小约为 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)

有没有办法部分打开文件,然后转到下一部分,从而减少一次使用的内存?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com