for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Smart\EtlBundle\Extractor;
/**
* Nicolas Bastien <[email protected]>
*/
class CsvEntityExtractor extends AbstractFolderExtrator implements ExtractorInterface
{
use EntityExtractorTrait;
* @inheritDoc
protected function getFileExtension()
return 'csv';
}
protected function extractFileContent($filepath)
$file = new \SplFileObject($filepath);
//csv file have to be formatted with headers on the first line
$headers = $file->fgetcsv();
$nbHeaders = count($headers);
$datas = [];
while (!$file->eof()) {
$csvData = $file->fgetcsv();
if (count($csvData) != $nbHeaders) {
continue;
$datas[] = array_combine($headers, $csvData);
return $datas;