izzle/csv

The CSV Library

Installs: 21

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:project

1.0.2 2018-02-14 15:00 UTC

This package is auto-updated.

Last update: 2024-10-17 22:42:16 UTC


README

What is "Izzle CSV"?

Izzle CSV is a highly memory efficient, flexible and extendable open-source CSV import library.

use Izzle\Csv\Reader;
use Izzle\Csv\Config;
use Izzle\Csv\Interpreter;

$interpreter = (new Interpreter())->addObserver(function (array $line) {
    var_dump($line);
});

$csv = new Reader((new Config())->setDelimiter(';')->setIgnoreHeaderLine(true));
$csv->parse(__DIR__ . '/data.csv', $interpreter);

Requirements

  • PHP 7.0 or later

Installation

Install composer in your project:

curl -s http://getcomposer.org/installer | php

Create a composer.json file in your project root:

{
    "require": {
        "izzle/csv": "*"
    }
}

Install via composer:

php composer.phar install

Documentation

Configuration

Import configuration:

use Izzle\Csv\Config;

$config = new Config();
$config
    ->setDelimiter("\t") // Customize delimiter. Default value is comma(,)
    ->setEnclosure("'")  // Customize enclosure. Default value is double quotation(")
    ->setEscape("\\")    // Customize escape character. Default value is backslash(\)
    ->setToCharset('UTF-8') // Customize target encoding. Default value is null, no converting.
    ->setFromCharset('SJIS-win') // Customize CSV file encoding. Default value is null.
;