PHP code example of league / csv-doctrine

1. Go to this page and download the library: Download league/csv-doctrine library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

league / csv-doctrine example snippets




use Doctrine\Common\Collections\Criteria;use League\Csv\Doctrine as CsvDoctrine;use League\Csv\Reader;

$csv = Reader::createFromPath('/path/to/my/file.csv');
$csv->setHeaderOffset(0);
$csv->setDelimiter(';');

$criteria = Criteria::create()
    ->andWhere(Criteria::expr()->eq('prenom', 'Adam'))
    ->orderBy( [ 'annee' => 'ASC', 'foo' => 'desc', ] )
    ->setFirstResult(3)
    ->setMaxResults(10)
;

$resultset = CsvDoctrine\src\CriteriaConverter::convert($criteria)->process($csv);



use League\Csv\Reader;
use League\Csv\Statement;

$csv = Reader::createFromPath('/path/to/my/file.csv');
$csv->setHeaderOffset(0);
$csv->setDelimiter(';');

$criteria = Statement::create()
    ->andWhere('prenom', '=', 'Adam')
    ->orderByAsc('annee')
    ->orderByDesc('foo')
    ->offset(3)
    ->limit(10);
    
$resultset = $criteria->process($csv);