grido
grido copied to clipboard
CSV export: cse fputcsv instead of custom $escape and $print
How about using fputcsv instead of custom escaping and custom print?
$print = function(array $row) {
$out = fopen('php://output', 'w');
fputcsv($out, $row, ";");
fclose($out);
};
Can you explain your troubles with Export?
When I was exporting ~25MB CSV, the CSV was malformatted and could not be opened. Another issue was that $escape
wraps empty cells to ""
which eg. Numbers on OS X displays as a column with ""
.
When I created my own Export with fputcsv
all worked.
In other words, PHP's fputcsv
seems to do a better job that your custom $escape
and $print
, it also seems to be faster and the code is smaller.
It's just a suggestion :)
I already used fputcsv()
in export. I don't remember why this method is not used, but referenced commit resolved marked issues (from commit msg).
I'll really appreciate pull request with your changes in export class and also in test-cases (there should be test data which does not work with current export)