2017 © Pedro Peláez
 

library csv

A library to read and write CSV files.

image

ork/csv

A library to read and write CSV files.

  • Saturday, February 10, 2018
  • by AlexHowansky
  • Repository
  • 0 Watchers
  • 0 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 6 % Grown

The README.md

Ork CSV

Ork CSV is a library for reading and writing CSV files., (*1)

Latest Version PHP License PHPStan Test Status [Code Coverage][6], (*2)

Installation

composer require ork/csv

Reader

Ork CSV provides a reader to parse delimited files into arrays. The reader is implemented as an iterator that yields the contents of one CSV line per iteration. If the file has a header line with column names, each yielded array will be associative, keyed by the names in the header. If the file does not have a header line with columns names, each yielded array will be indexed., (*3)

For example, a file with a header line:, (*4)

ID,Name,Size
1,foo,large
2,bar,small
$csv = new \Ork\Csv\Reader('/path/to/file.csv');
foreach ($csv as $row) {
    print_r($row);
}
Array
(
    [ID] => 1
    [Name] => foo
    [Size] => large
)
Array
(
    [ID] => 2
    [Name] => bar
    [Size] => small
)

A file without a header line:, (*5)

1,foo,large
2,bar,small
$csv = new \Ork\Csv\Reader(file: '/path/to/file.csv', hasHeader: false);
foreach ($csv as $row) {
    print_r($row);
}
Array
(
    [0] => 1
    [1] => foo
    [2] => large
)
Array
(
    [0] => 2
    [1] => bar
    [2] => small
)

Writer

Ork CSV provides a writer that will track columns and automatically generate an appropriate header line., (*6)

$csv = new \Ork\Csv\Writer('/path/to/file.csv');
$csv->write([
    'Id' => 1,
    'Name' => 'foo',
    'Size' => 'large',
]);
$csv->write([
    'Id' => 2,
    'Name' => 'bar',
    'Size' => 'small',
]);
Id,Name,Size
1,foo,large
2,bar,small

See the docs directory for full details., (*7)

The Versions

10/02 2018

dev-master

9999999-dev http://github.com/AlexHowansky/ork-csv

A library to read and write CSV files.

  Sources   Download

MIT

The Requires

 

The Development Requires

csv ork

02/05 2017

1.0.2

1.0.2.0 http://github.com/AlexHowansky/ork-csv

A library to read and write CSV files.

  Sources   Download

MIT

The Requires

 

The Development Requires

csv ork

11/04 2017

1.0.1

1.0.1.0 http://github.com/AlexHowansky/ork-csv

A library to read and write CSV files.

  Sources   Download

MIT

The Requires

 

The Development Requires

csv ork

10/04 2017

1.0.0

1.0.0.0 http://github.com/AlexHowansky/ork-csv

A library to read and write CSV files.

  Sources   Download

MIT

The Requires

 

The Development Requires

csv ork