2017 © Pedro Peláez
 

library php_component_csv

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.6 and above

image

net_bazzline/php_component_csv

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.6 and above

  • Friday, January 12, 2018
  • by artodeto
  • Repository
  • 5 Watchers
  • 5 Stars
  • 520 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 23 Versions
  • 0 % Grown

The README.md

CSV Handling Component for PHP

This project aims to deliver an easy to use and free as in freedom php compontent for dealing with csv files (read and write)., (*1)

This component is heavily influenced by jwage/easy-csv. It was mainly created because of missing compatibility with php 5.6 and no official packagist support from jwage/easy-csv., (*2)

The build status of the current master branch is tracked by Travis CI: Build Status Latest stable, (*3)

The scrutinizer status are: code quality, (*4)

The versioneye status is: Dependency Status, (*5)

Take a look on openhub.net., (*6)

The current change log can be found here., (*7)

Benefits

  • low and stable memory usage (give it a try by using benchmarkReader and benchmarkWriter)
  • works with PHP 5.6 and above
  • __invoke() implemented to use it as function
  • unified reader and writer
  • adapter to easy up migration from EasyCsv - 0.0.1 to this component
  • usage of filters - control what comes in and what comes out
  • reader
    • implemented iterator
    • readOne();
    • readMany();
    • readAll();
  • writer
    • copy();
    • delete();
    • move();
    • truncate();
    • writeOne();
    • writeMany();
    • writeAll(); //truncates file and writes content

Install

By Hand

mkdir -p vendor/net_bazzline/php_component_csv
cd vendor/net_bazzline/php_component_csv
git clone https://github.com/bazzline/php_component_csv .

With Packagist

composer require net_bazzline/php_component_csv:dev-master

Usage

Reader

Read Content

$reader = new Reader('my/file.csv');
//I am using json_encode() since there is no official and best way how to
// output arrays on the command line.

//read one line
echo json_encode($reader->readOne()) . PHP_EOL;

//read 10 lines
foreach ($reader->readMany(10) as $line) {
    echo json_encode($line) . PHP_EOL;
}

//read all lines
foreach ($reader->readAll() as $line) {
    echo json_encode($line) . PHP_EOL;
}

By Iteration

$reader = new Reader('my/file.csv');
//I am using json_encode() since there is no official and best way how to
// output arrays on the command line.

if ($reader->hasHeadline()) {
    echo 'headlines: ' . json_encode($reader->readHeadline());
}

foreach ($reader as $line) {
    echo json_encode($line) . PHP_EOL;
}

By Using As A Function

$reader = new Reader('my/file.csv');
//I am using json_encode() since there is no official and best way how to
// output arrays on the command line.

while ($line = $reader()) {
    echo json_encode($line) . PHP_EOL;
}

Writer

Write Content

By Iteration

//$headlines contains a php array
//$lines contains a php array of arrays
$writer = new Writer('my/file.csv');

$writer->writeHeadline($headlines);

foreach ($lines as $line) {
    $writer->writeOne($line);
}

At Once

//$headlines contains a php array
//$lines contains a php array of arrays
$writer = new Writer('my/file.csv');

$writer->writeHeadline($headlines);
$writer->writeMany($lines);

By Using As A Function

//$line contains a php array
//$lines contains a php array of arrays
$writer = new Writer('my/file.csv');

$writer($line);

foreach ($lines as $line) {
    $writer($line);
}

Truncate

$writer = new Writer('my/file.csv');

$writer->truncate();

Copy

$writer = new Writer('my/file.csv');

$writer->copy('my/my_first_copy.csv');    //writer will still write into "file.csv"

$writer->copy('my/my_second_copy.csv', true);    //writer will write in "my_second_copy.csv"

Move

$writer = new Writer('my/file.csv');

$writer->move('my/new_name.csv');   //writer will write in "new_name.csv"

API

API is available at bazzline.net., (*8)

Other Great Components

Hall of Fame - The list of contributors

Contributing

Please see CONTRIBUTING for details., (*9)

Final Words

Star it if you like it :-). Add issues if you need it. Pull patches if you enjoy it. Write a blog entry if you use it. Donate something if you love it :-]., (*10)

The Versions

12/01 2018

dev-master

9999999-dev

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.6 and above

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

psr csv read write filesystem component php filter export easy iterator php7 adapter memory import psr-4 usage reusable invoke headline bazzline free as in freedom lgpl easycsv tranversable low php56

30/05 2016

1.5.14

1.5.14.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

psr csv read write filesystem component php filter export easy iterator adapter memory import psr-4 usage reusable invoke headline bazzline free as in freedom lgpl easycsv tranversable low

16/03 2016

1.5.13

1.5.13.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

psr csv read write filesystem component php filter export easy iterator adapter memory import psr-4 usage reusable invoke headline bazzline free as in freedom lgpl easycsv tranversable low

22/02 2016

1.5.12

1.5.12.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

psr csv read write filesystem component php filter export easy iterator adapter memory import psr-4 usage reusable invoke headline bazzline free as in freedom lgpl easycsv tranversable low

20/01 2016

1.5.11

1.5.11.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter memory import usage reusable invoke headline free as in freedom lgpl easycsv tranversable low

12/01 2016

1.5.10

1.5.10.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter memory import usage reusable invoke headline free as in freedom lgpl easycsv tranversable low

11/12 2015

1.5.9

1.5.9.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter memory import usage reusable invoke headline free as in freedom lgpl easycsv tranversable low

08/11 2015

1.5.8

1.5.8.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter memory import usage reusable invoke headline free as in freedom lgpl easycsv tranversable low

07/10 2015

1.5.7

1.5.7.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter memory import usage reusable invoke headline free as in freedom lgpl easycsv tranversable low

11/09 2015

1.5.6

1.5.6.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter memory import usage reusable invoke headline free as in freedom lgpl easycsv tranversable low

09/09 2015

1.5.5

1.5.5.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter memory import usage reusable invoke headline free as in freedom lgpl easycsv tranversable low

09/09 2015

1.5.4

1.5.4.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter memory import usage reusable invoke headline free as in freedom lgpl easycsv tranversable low

26/08 2015

1.5.3

1.5.3.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter memory import usage reusable invoke headline free as in freedom lgpl easycsv tranversable low

06/07 2015

1.5.2

1.5.2.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter memory import usage reusable invoke headline free as in freedom lgpl easycsv tranversable low

04/07 2015

1.5.1

1.5.1.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter memory import usage reusable invoke headline free as in freedom lgpl easycsv tranversable low

02/07 2015

1.5.0

1.5.0.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter memory import usage reusable invoke headline free as in freedom lgpl easycsv tranversable low

02/07 2015

1.4.0

1.4.0.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter memory import usage reusable invoke headline free as in freedom lgpl easycsv tranversable low

26/06 2015

1.3.0

1.3.0.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter memory import usage reusable invoke headline free as in freedom lgpl easycsv tranversable low

25/06 2015

1.2.0

1.2.0.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter memory import usage reusable invoke headline free as in freedom lgpl easycsv tranversable low

10/06 2015

1.1.0

1.1.0.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter import reusable invoke headline free as in freedom lgpl easycsv tranversable

07/06 2015

1.0.0

1.0.0.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter import reusable invoke headline free as in freedom lgpl easycsv tranversable

22/05 2015

0.2.0

0.2.0.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

csv read write filesystem component php filter export easy iterator adapter import reusable invoke headline lgpl easycsv tranversable

17/05 2015

0.1.0

0.1.0.0

free as in freedom php component to easy up usage (reading and writing) of csv files for php 5.3 and above

  Sources   Download

LGPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

csv read write filesystem component php filter export adapter import headline lgpl easy csv