dongyi7901 2014-12-19 03:19
浏览 36

在php中加载“file vs SplFileObject”的巨大文件

I am trying to read a text file with 7 million lines hereby named HUGE. I am trying to read the first 10 thousand lines and then delete them. I am presently using SplFileObject like this...

    $file = new SplFileObject(FILENAME);
    for ($i = $start; $i <= $end; $i++) {
        $file->seek($i);
        $lines .= $file->current();
    }
    return($lines);

I do not yet have HUGE. I need to know if SplFileObject can load such a huge file. I need to calculate the length of HUGE every time I remove lines from it. "file" seems promising since count(array_HUGE) will give me the length immediately. I need to make a design decision now. Which of the 2 has a smaller footprint and is faster in loading HUGE?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 易康econgnition精度验证
    • ¥15 线程问题判断多次进入
    • ¥15 msix packaging tool打包问题
    • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致