PHP code example of jotaelesalinas / php-data-streams

1. Go to this page and download the library: Download jotaelesalinas/php-data-streams 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/ */

    

jotaelesalinas / php-data-streams example snippets


use JLSalinas\DataStreams\Csv\CsvReader;

$reader = new CsvReader(__DIR__ . '/customers.csv');

foreach ($reader as $customer) {
    echo $customer['name'] . PHP_EOL;
}

use JLSalinas\DataStreams\Csv\CsvReader;

$reader = new CsvReader(__DIR__ . '/customers.csv');

foreach ($reader as $customer) {
    echo $customer['name'] . PHP_EOL;
}

use JLSalinas\DataStreams\Csv\CsvWriter;

$writer = new CsvWriter(__DIR__ . '/export.csv');
$writer->write(['name' => 'Ada', 'email' => '[email protected]']);
$writer->write(['name' => 'Grace', 'email' => '[email protected]']);
$writer->close();

use JLSalinas\DataStreams\Json\JsonReader;

$reader = new JsonReader(__DIR__ . '/events.ndjson');

foreach ($reader as $event) {
    var_dump($event);
}

  use JLSalinas\RWGen\CsvReader;
  

  use JLSalinas\DataStreams\Csv\CsvReader;