A few questions about performance of phpexcel

Topics: Developer Forum, User Forum
May 6, 2014 at 3:49 PM
I wrote a code to extract certain fields from a csv file but the problem is that in terms on performance its is a big fail. It takes about 2-4 minutes to process a 9MB csv file that has about 100000 rows of data.

I have tried it on a server with maximum amount of memory alloted to the php engine and the machine is a hard core one which only means that my code is bad.

my question is, is phpexcel a good choice to extract data which will have millions of rows of data. The machine that i have is very good so no worries in terms of cpu and memory.

Hope people don't find this silly.
Coordinator
May 6, 2014 at 4:15 PM
No it isn't a good choice.

If you're working purely with CSV data, then use PHP's built-in fgetcsv() function for reading CSV files, or even MySQL's LOAD DATA INFILE (assuming you're using MySQL, though most databases have an equivalent). This allows you to process a CSV file using a minimal amount of processing and memory overhead.

PHPExcel is designed for working with spreadsheet files, with formatted data, and formulae, and other spreadsheet features that you don't find in CSV files; and while it will work with CSV files as well, it has a large overhead in comparison with the built-in PHP function or the database itself.