Laravel-Excel大量导入 [英] Laravel-Excel massive import

查看:1849
本文介绍了Laravel-Excel大量导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有一个包含28k行的excel文件.
我想加载它,然后将其插入数据库,但是它刚刚停止了. (空格)
我尝试将数据缩减为5k,并且可以正常工作,但是速度太慢
我也尝试使用只有5k数据的 chunk 最大执行时间超过了300秒".
这是代码

So, I have an excel file with 28k rows.
I want to load it, then insert into database, but it was just stopped. (blank space)
I've tried to reduce into 5k data, and it worked, but is too slow
I also tried using chunk, with only 5k data, but I got "Maximum execution time of 300 seconds exceeded".
here's the code

Excel::filter('chunk')->load(storage_path('excel/exports/').$fileName)->chunk(1000, function($results)
    {
        foreach($results as $key)
        {
            // even nothing to do
        }
    });

5k行真的那么大吗?
还是我做错了?
谢谢.

Is 5k row really that big to handle?
Or am I doing it wrong?
Thanks.

推荐答案

您正在按书进行. (例如,使用卡盘)
但是28k行要处理的数据很多.

You're doing it by the book. (Using chuck, for example)
But 28k rows is much data to handle.

您可以编辑您的最大执行时间.
请参阅: http://php.net/manual/en/function.set -time-limit.php

You can edit your maximum execution time.
see: http://php.net/manual/en/function.set-time-limit.php

bool set_time_limit ( int $seconds )

希望这会有所帮助.

这篇关于Laravel-Excel大量导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆