2017 © Pedro Peláez
 

library reactphp-csv

image

rakdar/reactphp-csv

  • Sunday, March 18, 2018
  • by Rakdar
  • Repository
  • 1 Watchers
  • 2 Stars
  • 65 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 44 % Grown

The README.md

reactphp-csv

Introduction

Uses PHPs internal fgetcsv function to parse data into an array or vice versa to file/stream., (*1)

Installation

$ composer require rakdar/reactphp-csv

Read from csv-file

$loop = React\EventLoop\Factory::create();

$inputFd = fopen('country-codes.csv', 'r');
$input = new Rakdar\React\Csv\Reader(
    new React\Stream\ReadableResourceStream($inputFd, $loop)
);

$input->on('data', function ($field) {
    echo $field[10] . PHP_EOL;
});

$loop->run();

Write to csv-file

$loop = React\EventLoop\Factory::create();

$outputFp = fopen('testfile.csv', 'w');
$output = new Rakdar\React\Csv\Writer(
    new React\Stream\WritableResourceStream($outputFp, $loop)
);
$output->write(['Header 1', 'Header 2', 'Header 3']);
$output->write(['Col 1.1', 'Col 1.2', 'Col 1.3']);
$output->write(['Col 2.1', 'Col 2.2', 'Col 2.3']);

$output->close();

$loop->run();

The Versions

18/03 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

18/03 2018

0.2.1

0.2.1.0

  Sources   Download

MIT

The Requires

 

14/02 2018

0.2.0

0.2.0.0

  Sources   Download

MIT

The Requires

 

20/12 2017

0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires