36 lines
814 B
PHP
36 lines
814 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Jobs;
|
||
|
|
|
||
|
|
abstract class CsvJobs extends XArcadiaFlux
|
||
|
|
{
|
||
|
|
|
||
|
|
/**
|
||
|
|
* parse csv file
|
||
|
|
*/
|
||
|
|
protected function parseCsv($csvFile) {
|
||
|
|
$file_handle = fopen($csvFile, 'r');
|
||
|
|
while (!feof($file_handle)) {
|
||
|
|
$line_of_text[] = fgetcsv($file_handle, 0, ";");
|
||
|
|
if(!end($line_of_text)) {
|
||
|
|
//supprime les lignes vides du csv
|
||
|
|
array_pop($line_of_text);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
fclose($file_handle);
|
||
|
|
return $line_of_text;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Is the file to be ignored
|
||
|
|
*
|
||
|
|
* @param string $filename
|
||
|
|
* @return boolean
|
||
|
|
*/
|
||
|
|
protected function fileHasToBeIgnored(string $filename): bool
|
||
|
|
{
|
||
|
|
return in_array($filename, $this->ignoreFiles) or !$this->checkExtension($filename, 'csv');
|
||
|
|
}
|
||
|
|
}
|