PHPackages                             spyrit/colibri-csv - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. spyrit/colibri-csv

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

spyrit/colibri-csv
==================

Lightweight and performant CSV reader and writer library

v1.3.0(1y ago)032.8k↓40.9%1LGPL-3.0+PHPPHP &gt;=7.4

Since Feb 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/spyrit/colibri-csv)[ Packagist](https://packagist.org/packages/spyrit/colibri-csv)[ RSS](/packages/spyrit-colibri-csv/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (23)Used By (1)

CSanquer ColibriCSV
===================

[](#csanquer-colibricsv)

**LOOKING FOR NEW MAINTAINER**

[![Latest Stable Version](https://camo.githubusercontent.com/4e3a425d6e9b9ab0ff61e465d7fbad048f504dea2c5f9825c565a3a3ad9ca9ec/68747470733a2f2f706f7365722e707567782e6f72672f6373616e717565722f636f6c696272692d6373762f762f737461626c652e706e67)](https://packagist.org/packages/csanquer/colibri-csv)[![Latest Unstable Version](https://camo.githubusercontent.com/0504401ccc2ff17780b433c1245911bd273b76f374202b860cbecbe820859f9b/68747470733a2f2f706f7365722e707567782e6f72672f6373616e717565722f636f6c696272692d6373762f762f756e737461626c652e706e67)](https://packagist.org/packages/csanquer/colibri-csv)[![Build Status](https://camo.githubusercontent.com/e9aa6784f23d6525bcfc754e1e487be279c37cc6e236821464302d2bbf30e6eb/68747470733a2f2f7472617669732d63692e6f72672f6373616e717565722f636f6c696272692d6373762e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/csanquer/colibri-csv)[![Code Coverage](https://camo.githubusercontent.com/bc157775e592be85ce16f599d55aa4a84c559d10ff40b54a2ce7da097d40c704/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6373616e717565722f636f6c696272692d6373762f6261646765732f636f7665726167652e706e673f733d62313164303834646232303336383231346330306161643664326134333465343533306335393133)](https://scrutinizer-ci.com/g/csanquer/colibri-csv/)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/7c51db63b52ed20d5caf34ca42b680193b0d7ed8ee23e81032cf03bf994b9191/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6373616e717565722f636f6c696272692d6373762f6261646765732f7175616c6974792d73636f72652e706e673f733d39303966663163636161666336323934653461323530633731643865383562313133623436333866)](https://scrutinizer-ci.com/g/csanquer/colibri-csv/)[![SensioLabsInsight](https://camo.githubusercontent.com/4192918ddbd82ac088d22a123dda8e012c0af27bec25bd36b80e3e85bd9accc1/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f37666565616237342d373663302d343430342d623964382d3030396430376330663635322f6d696e692e706e67)](https://insight.sensiolabs.com/projects/7feeab74-76c0-4404-b9d8-009d07c0f652)

[![Dependency Status](https://camo.githubusercontent.com/eb1e8a1b94cb8e4b925ca5ebbbb178fccfe3ef29867df447975653855d2b04ae/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3532663465363864656331333735646337623030303134642f62616467652e706e67)](https://www.versioneye.com/user/projects/52f4e68dec1375dc7b00014d)[![License](https://camo.githubusercontent.com/0b511b0b8d114f4d374d1dd3aac4026e07b387cdc28e75b40125e49205936105/68747470733a2f2f706f7365722e707567782e6f72672f6373616e717565722f636f6c696272692d6373762f6c6963656e73652e706e67)](https://packagist.org/packages/csanquer/colibri-csv)[![Daily Downloads](https://camo.githubusercontent.com/fcca1bec0fa1807c4291a1a488cdffb3166538527c29579a03b55571ee896b2c/68747470733a2f2f706f7365722e707567782e6f72672f6373616e717565722f636f6c696272692d6373762f642f6461696c792e706e67)](https://packagist.org/packages/csanquer/colibri-csv)[![Monthly Downloads](https://camo.githubusercontent.com/7cc5f2073e8d62b36fd32c6e29a17bb39c2c74950d02463babeac13d7f8b87a0/68747470733a2f2f706f7365722e707567782e6f72672f6373616e717565722f636f6c696272692d6373762f642f6d6f6e74686c792e706e67)](https://packagist.org/packages/csanquer/colibri-csv)[![Total Downloads](https://camo.githubusercontent.com/3b1ca1e774fb7cbf3414ee0503939d3c821d6db2d88be9b7436a2f29fcc1828b/68747470733a2f2f706f7365722e707567782e6f72672f6373616e717565722f636f6c696272692d6373762f646f776e6c6f6164732e706e67)](https://packagist.org/packages/csanquer/colibri-csv)

A lightweight, simple and performant CSV Reader/Writer PHP 7.4+ Library, inspired from Python CSV Module. Fully Tested, very memory efficient and able to parse/write CSV files that weigh over 100 Mb.

This is a fork of [Spyrit LightCSV library](https://github.com/spyrit/LightCsv), I have developed previously in this company.

Installation
------------

[](#installation)

- get composer  and install dependencies

```
curl -s https://getcomposer.org/installer | php
```

- add "[https://packagist.org/packages/csanquer/colibri-csv](csanquer/colibri-csv)" package to your composer.json file require section

```
php composer.phar require csanquer/colibri-csv:^1.0
```

- install dependencies

```
php composer.phar install
```

- include vendor/autoload.php

How To
------

[](#how-to)

\###Read

Instanciate a new CSVReader with the following CSV parameters:

- field delimiter (default for Excel = ; )
- field enclosure character (default for Excel = " )
- character encoding = (default for Excel = CP1252 )
- end of line character (default for Excel = "\\r\\n" )
- escape character (default for Excel = "\\" )
- first\_row\_header : (default for excel = false) use the first CSV row as header
- UTF8 BOM (default false) force removing BOM
- transliteration (default for Excel = null ) available options : 'translit', 'ignore', null
- force encoding detection (default for Excel = false )
- skip empty lines (default for Excel = false ) lines which all values are empty
- trim (default = false for Excel) trim all values

```
use CSanquer\ColibriCsv\CsvReader;

// create the reader
$reader = new CsvReader(array(
    'delimiter' => ';',
    'enclosure' => '"',
    'encoding' => 'CP1252',
    'eol' => "\r\n",
    'escape' => "\\",
    'first_row_header' => false,
    'bom' => false,
    'translit' => 'translit',
    'force_encoding_detect' => false,
    'skip_empty' => false,
    'trim' => false,
));

//Open the csv file to read
$reader->open('test.csv');

// or open an existing stream resource
$stream = fopen('test.csv', 'rb');
$reader->open($stream);

// or read an existing CSV string by creating a temporary in-memory file stream (not recommended for large CSV)
$reader->createTempStream('lastname,firstname,age
Martin,Durand,"28"
Alain,Richard,"36"
');

//Read each row
foreach ($reader as $row) {
    // do what you want with the current row array : $row
}

// or get all rows in one call (not recommended for large CSV)
$csvRows = $reader->getRows();

//close the csv file stream
$reader->close();
```

\###Write

Instanciate a new CSVWriter with the following CSV parameters:

- field delimiter (default for Excel = ; )
- field enclosure character (default for Excel = " )
- character encoding = (default for Excel = CP1252 )
- end of line character (default for Excel = "\\r\\n" )
- escape character (default for Excel = "\\" )
- first\_row\_header : (default for excel = false) use the PHP keys as CSV headers and write a first row with them
- enclosing\_mode (default = 'minimal'), possible values :
    - all : always enclose string
    - minimal : enclose string only if the delimiter, enclosure or line ending character is present
    - nonumeric : enclose string only if the value is non numeric (other character than digits and dot)
- escape\_double (default = true) if true double the enclosure to escape it, else escape it with escape character
- UTF8 BOM (default false) force writing BOM if encoding is UTF-8
- transliteration (default for Excel = null ) available options : 'translit', 'ignore', null
- trim (default = false for Excel) trim all values

```
use CSanquer\ColibriCsv\CsvWriter;

// create the writer
$writer = new CsvWriter(array(
    'delimiter' => ';',
    'enclosure' => '"',
    'encoding' => 'CP1252',
    'enclosing_mode' => 'minimal',
    'escape_double' => true,
    'eol' => "\r\n",
    'escape' => "\\",
    'bom' => false,
    'translit' => 'translit',
    'first_row_header' => false,
    'trim' => false,
));

//Open the csv file to write
$writer->open('test.csv');

// or open an existing stream resource
$stream = fopen('test.csv', 'wb');
$writer->open($stream);

// or create an empty temporary in-memory file stream to write in and get CSV text later
// (not recommended for large CSV file)
$writer->createTempStream();

//Write a row
$writer->writeRow(array('a', 'b', 'c'));

//Write multiple rows at the same time
$writer->writeRows(array(
    array('d', 'e', 'f'),
    array('g', 'h', 'i'),
    array('j', 'k', 'l'),
));

// get the CSV Text as plain string
$writer->getFileContent();

//close the csv file
$writer->close();
```

### Configuration : Dialect class

[](#configuration--dialect-class)

Instead of giving directly an array to the CsvReader or CsvWriter constructor, you can create a Dialect object, use setter methods to change parameters and pass it to the CsvReader (or CsvWriter) :

*Be careful, the options 'force\_encoding\_detect', 'skip\_empty' and 'trim' decrease significantly the performances*

```
use CSanquer\ColibriCsv\Dialect;
use CSanquer\ColibriCsv\CsvReader;
use CSanquer\ColibriCsv\CsvWriter;

// create a dialect with some CSV parameters
$dialect = new Dialect(array(
    'delimiter' => ';',
    'enclosure' => '"',
    'enclosing_mode' => 'minimal',
    'encoding' => 'CP1252',
    'eol' => "\r\n",
    'escape' => "\\",
    'escape_double' => true,
    'bom' => false,
    'translit' => 'translit',
    'force_encoding_detect' => false,
    'skip_empty' => false,
    'trim' => false,
);

// change a parameter
$dialect->setLineEndings("\n");

// create the reader
$reader = new CsvReader($dialect);

//or a writer
$writer = new CsvWriter($dialect);
```

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4
- extension mbstring

Suggested :

- extension iconv

Tests
-----

[](#tests)

run unit tests with phpunit :

```
vendor/bin/phpunit
```

run benchmark test :

```
php tests/benchmark_test.php
```

Licensing
---------

[](#licensing)

This library is a Fork of Spyrit LightCSV

License LGPL 3

- Copyright (C) 2012-2013 Spyrit Systeme (Spyrit LightCSV)
- Copyright (C) 2014 Charles Sanquer

This file is part of ColibriCSV.

ColibriCSV is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

ColibriCSV is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with ColibriCSV. If not, see .

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 91.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~213 days

Recently: every ~890 days

Total

19

Last Release

647d ago

PHP version history (3 changes)v1.0.0PHP &gt;=5.3.3

v1.2.0PHP &gt;=5.4

v1.3.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/22ef5c808b13d78c94fd3d55407740ca250bb116263cb0be3ad1c2e6f26d117f?d=identicon)[Spyrit\_SI](/maintainers/Spyrit_SI)

---

Top Contributors

[![csanquer](https://avatars.githubusercontent.com/u/372677?v=4)](https://github.com/csanquer "csanquer (53 commits)")[![ldaspt](https://avatars.githubusercontent.com/u/72605285?v=4)](https://github.com/ldaspt "ldaspt (3 commits)")[![pyguerder](https://avatars.githubusercontent.com/u/6534215?v=4)](https://github.com/pyguerder "pyguerder (2 commits)")

---

Tags

parserexportcsvwriterreaderimport

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/spyrit-colibri-csv/health.svg)

```
[![Health](https://phpackages.com/badges/spyrit-colibri-csv/health.svg)](https://phpackages.com/packages/spyrit-colibri-csv)
```

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[league/csv

CSV data manipulation made easy in PHP

3.5k166.1M646](/packages/league-csv)[csanquer/colibri-csv

Lightweight and performant CSV reader and writer library

16161.7k4](/packages/csanquer-colibri-csv)[goodby/csv

CSV import/export library

9555.6M23](/packages/goodby-csv)[faisalman/simple-excel-php

Easily parse / convert / write between Microsoft Excel XML / CSV / TSV / HTML / JSON / etc formats

582599.4k1](/packages/faisalman-simple-excel-php)[shuchkin/simplecsv

Parse and retrieve data from CSV files. Export data to CSV.

5192.4k](/packages/shuchkin-simplecsv)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
