简体   繁体   中英

how to read very large csv files using phpexcel reader

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM