Change CSV delimiter to comma in PHP

2

I have a small problem, I have a CSV file with a ; separator, the problem is that when I try to create the object with:

$objReader = PHPExcel_IOFactory::createReader('CSV');

It returns the following error:

is not recognised as an OLE file

I understand that the problem is because a CSV has to be delimited by a comma, and not by semicolons, I have tried to change the extension manually, but the file becomes corrupt, and it does not allow me to open it with Excel5, so my question is if you could read the file and replace the separator that comes with the comma.

    
asked by Imanol 14.03.2016 в 16:13
source

1 answer

2

Use setDelimiter to solve your problem:

$objReader = PHPExcel_IOFactory::createReader('CSV');
$objReader->setDelimiter(';');
//resto del código...
    
answered by 14.03.2016 / 16:57
source