使用 PHPExcel 加载 38MB .csv 文件时,huge text node: out of memory
即使我已将其设置php memory_limit
为 1024M,我也会收到错误消息。
知道如何加载大型 .csv 文件吗?
错误
Error loading file "data.csv": Warning: DOMDocument::loadHTMLFile(): xmlSAX2Characters: huge text node: out of memory in /var/www/site/data.csv, line: 264094 in /var/www/site/vendor/CodePlex/PHPExcel/PHPExcel/Reader/HTML.php line 458
PHP 代码
ini_set('memory_limit', '1024M');
$inputFileName = '/var/www/site/data.csv';
$phpExcel = new PHPExcel;
// Read your Excel workbook
try
{
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
}
catch(Exception $e)
{
die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage());
}
php.ini
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M