PHPackages                             xp-framework/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. xp-framework/csv

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

xp-framework/csv
================

Contains the XP Framework's CSV API

v11.1.0(2y ago)062.2k↓17.9%BSD-3-ClausePHPPHP &gt;=7.0.0

Since Jan 10Pushed 2y ago1 watchersCompare

[ Source](https://github.com/xp-framework/csv)[ Packagist](https://packagist.org/packages/xp-framework/csv)[ Docs](http://xp-framework.net/)[ RSS](/packages/xp-framework-csv/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (17)Used By (0)

CSV File handling for the XP Framework
======================================

[](#csv-file-handling-for-the-xp-framework)

[![Build status on GitHub](https://github.com/xp-framework/csv/workflows/Tests/badge.svg)](https://github.com/xp-framework/csv/actions)[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)[![Latest Stable Version](https://camo.githubusercontent.com/e3f444aaac12f2fb9d4bd1145a630c85aea28182d6d1a859ab43347e4eac2cbd/68747470733a2f2f706f7365722e707567782e6f72672f78702d6672616d65776f726b2f6373762f76657273696f6e2e706e67)](https://packagist.org/packages/xp-framework/csv)

Contains the XP Framework's CSV API

Reading
-------

[](#reading)

CSV data can be read off any input stream, reader or channel:

```
use util\cmd\Console;
use text\csv\CsvListReader;
use io\streams\FileInputStream;

$csv= new CsvListReader(new FileInputStream('in.csv'));
Console::writeLine($csv->getHeaders());

while ($record= $csv->read()) {
  Console::writeLine('- ', $record);
}

$csv->close();
```

Writing
-------

[](#writing)

CSV data can be written to any output stream, writer or channel:

```
use util\cmd\Console;
use text\csv\CsvListWriter;
use io\streams\FileOutputStream;

$csv= new CsvListWriter(new FileOutputStream('out.csv'));

$csv->setHeader(['name', 'city', 'zip']);
$csv->write(['Timm', 'Karlsruhe', 76137]);
$csv->write(['Alex', 'Karlsruhe', 76131]);

$csv->close();
```

Character set conversion
------------------------

[](#character-set-conversion)

Character set decoding is accomplished by passing a TextReader or TextWriter instance with a given character set:

```
use text\csv\{CsvListReader, CsvListWriter};
use io\streams\{FileInputStream, FileOutputStream, TextReader, TextWriter};

// Read from in.csv, which is in cp1252
$in= new CsvListReader(new TextReader(new FileInputStream('in.csv'), 'cp1252'));

// Write to out.csv, converting everything to cp1252
$out= new CsvListWriter(new TextWriter(new FileOutputStream('out.csv'), 'cp1252'));
```

Format
------

[](#format)

CSV files usually use the semi-colon to separate values. Depending on the file we're parsing, this might be a different character. Both readers and writers accept an optional second parameter with which the format can be changed.

```
use text\csv\{CsvFormat, CsvListReader, CsvListWriter};

$format= (new CsvFormat())->withDelimiter(',');
$format= CsvFormat::$COMMAS;    // Short-hand for the above

$writer= new CsvListWriter(..., $format);
$reader= new CsvListReader(..., $format);
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 83.8% 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 ~224 days

Total

16

Last Release

786d ago

Major Versions

v6.2.0 → v7.0.02016-02-21

v7.1.0 → v8.0.02017-06-15

v8.0.2 → v9.0.02020-04-10

v9.0.0 → v10.0.02021-10-21

v10.2.0 → v11.0.02024-02-04

PHP version history (4 changes)v6.0.0PHP &gt;=5.4.0

v6.2.0PHP &gt;=5.5.0

v8.0.0PHP &gt;=5.6.0

v9.0.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/07d18d882c8b4aaf3466432f64018214f2771eda333202175431ee7233795376?d=identicon)[thekid](/maintainers/thekid)

---

Top Contributors

[![thekid](https://avatars.githubusercontent.com/u/696742?v=4)](https://github.com/thekid "thekid (14299 commits)")[![kiesel](https://avatars.githubusercontent.com/u/127769?v=4)](https://github.com/kiesel "kiesel (2390 commits)")[![ohinckel](https://avatars.githubusercontent.com/u/717217?v=4)](https://github.com/ohinckel "ohinckel (335 commits)")[![Stormwind](https://avatars.githubusercontent.com/u/836872?v=4)](https://github.com/Stormwind "Stormwind (13 commits)")[![andstefiul](https://avatars.githubusercontent.com/u/798415?v=4)](https://github.com/andstefiul "andstefiul (5 commits)")[![kusnier](https://avatars.githubusercontent.com/u/726429?v=4)](https://github.com/kusnier "kusnier (5 commits)")[![beorgler](https://avatars.githubusercontent.com/u/2027220?v=4)](https://github.com/beorgler "beorgler (3 commits)")[![treuter](https://avatars.githubusercontent.com/u/1067905?v=4)](https://github.com/treuter "treuter (3 commits)")[![ppetermann](https://avatars.githubusercontent.com/u/69334?v=4)](https://github.com/ppetermann "ppetermann (1 commits)")[![guel1973](https://avatars.githubusercontent.com/u/4669852?v=4)](https://github.com/guel1973 "guel1973 (1 commits)")

---

Tags

csvphpstreamxp-frameworkmodulexp

### Embed Badge

![Health badge](/badges/xp-framework-csv/health.svg)

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

PHPackages © 2026

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