0

I am trying to read a csv file of size 980mb using phpexcel reader, but my code is reading smaller files(upto 4mb), but how to read larger csv or excel files using phpexcel reader??[i am a fresher in php and phpexcel function too].Please help me it this possible? Thanks in advance.

Priya
  • 1
  • 3
  • [how to read large worksheets from large excel files with PHPExcel](http://stackoverflow.com/questions/4666746/how-to-read-large-worksheets-from-large-excel-files-27mb-with-phpexcel) – Mark Baker Dec 15 '16 at 10:14
  • [PHPExcel runs out of RAM](http://stackoverflow.com/questions/4817651/phpexcel-runs-out-of-256-512-and-also-1024mb-of-ram) – Mark Baker Dec 15 '16 at 10:16
  • And if all you're doing is reading a csv file, then PHP's built-in [fgetcsv()](http://www.php.net/manual/en/function.fgetcsv.php) function is much more efficient – Mark Baker Dec 15 '16 at 10:16

1 Answers1

0

If you don't care about how long it takes and how much memory it needs, you can simply increase the values for this script. Just add the following lines to the top of your script:

ini_set('memory_limit', '1024M');
ini_set('max_execution_time', '300');

With the function memory_get_usage() you can find out how much memory your script needs to find a good value for the memory_limit.

You might also want to have a look at fgets() which allows you to read a file line by line. I am not sure if that takes less memory, but I really think this will work. But even in this case you have to increase the max_execution_time to a higher value. you can increase excution time as per requirment.

Mirza Obaid
  • 1,707
  • 3
  • 23
  • 35
  • Thank for your reply. I am using codeigniter,i included these lines in my controller? but still i got this error - 'outofmemory' try allocate more memory space in phpexcelreader? – Priya Dec 15 '16 at 11:24