cakephp-csvview icon indicating copy to clipboard operation
cakephp-csvview copied to clipboard

Outputting large amounts of rows

Open asgraf opened this issue 7 years ago • 1 comments

I would like to generate really big csv files with large amounts of rows.

public function export()
{
    $this->viewBuilder()->className('CsvView.Csv');
    $milionsOfRows = $this->SomeBigTable->find()->enableBufferedResults(false)->all();

    $this->set('data',$milionsOfRows);
    $this->set('_serialize','data');
}

Currently this plugin generates complete csv content before outputting it to the browser. This can cause slowndowns or running out of memory when dealing with big number of rows. I think it would be good idea to stream csv output instead (and flush() it every 100 rows)

asgraf avatar May 15 '18 11:05 asgraf

Looks like this is possible as shown here.

Would you be interested in creating a pull request? For large responses, I normally generate on the backend and provide a notification to the user that their response is ready, rather than generate on the fly. What I'm trying to say is this isn't a problem I have in my applications, so I am unlikely to work on a fix.

josegonzalez avatar May 15 '18 14:05 josegonzalez