czproject/csv-iterator

Simple reading of CSV files.

v1.1.0 2018-06-22 10:11 UTC

README

Simple reading of CSV files.

Build Status

Become a Patron! Buy me a coffee

Installation

Download a latest package or use Composer:

composer require czproject/csv-iterator

CsvIterator requires PHP 5.4.0 or later.

Usage

id,name
1,Gandalf The White
$iterator = new CzProject\CsvIterator\CsvIterator('/path/to/file.csv');

// optional:
$iterator->setDelimiter(',');
$iterator->setEnclosure('"');
$iterator->setEscape('\\');
$iterator->setEncoding('UTF-8');

while (($row = $iterator->fetch()) !== NULL) {
	echo $row['id']; // prints '1'
	echo $row['name']; // prints 'Gandalf The White'
}

License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/