The League of Extraordinary Packages

Our Packages:

Presented by The League of Extraordinary Packages

CSV

CSV data manipulation made easy in PHP.

$ composer require league/csv

Usage

<?php
use League\Csv\Reader;
use League\Csv\Statement;

//load the CSV document
$csv = Reader::createFromPath('/path/to/your/csv/file.csv')
    ->setHeaderOffset(0)
    ->addStreamFilter('convert.iconv.ISO-8859-1/UTF-8')
;

//build a statement
$stmt = (new Statement())
    ->offset(10)
    ->limit(25)
;

//query your records from the document
$records = $stmt->process($csv)->fetchAll();

Highlights

The library was designed for developers who want to deal with CSV data using modern code and without the high levels of bootstrap and low-levels of usefulness provided by existing core functions or third party-code.

  1. Simple API

  2. Read and Write to CSV documents in a memory efficient and scalable way

  3. Support PHP Stream filtering capabilities

  4. Transform CSV documents into popular formats (JSON, XML or HTML)

  5. Framework-agnostic

Releases

Current Stable Release

League\Csv 8.0

  • Requires: PHP >= 5.5.0
  • Release Date: 2015-12-11
  • Supported Until: TBD

Full Documentation

No longer Supported

League\Csv 7.0

  • Requires: PHP >= 5.4.0
  • Release Date: 2015-02-19
  • Supported Until: 2016-06-11

Full Documentation

Once a new major version is released, the previous stable release remains supported for six more months through patches and security fixes.

Questions?

League\Csv was created by Ignace Nyamagana Butera. Find him on Twitter at @nyamsprod.