PHPackages                             plumphp/plum-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. plumphp/plum-csv

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

plumphp/plum-csv
================

PlumCsv includes CSV readers and writers for Plum. Plum is a data processing pipeline for PHP.

v0.4(10y ago)15.8k11MITPHPPHP &gt;=5.4

Since Mar 24Pushed 3y ago1 watchersCompare

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

READMEChangelog (5)Dependencies (4)Versions (10)Used By (1)

 [![Plum](https://camo.githubusercontent.com/a81342cbfd6f64a484988488ad37bbd0e665d0f14f65ec655ae986097447bfb6/687474703a2f2f63646e2e666c6f7269616e2e65632f706c756d2d6c6f676f2e737667)](https://camo.githubusercontent.com/a81342cbfd6f64a484988488ad37bbd0e665d0f14f65ec655ae986097447bfb6/687474703a2f2f63646e2e666c6f7269616e2e65632f706c756d2d6c6f676f2e737667)
==================================================================================================================================================================================================================================================================================================================================================================

[](#----)

> PlumCsv includes CSV readers and writers for Plum. Plum is a data processing pipeline for PHP.

[![Build Status](https://camo.githubusercontent.com/a9f25c38e1a1dd54227f4394413f187b0de781b31caa0f475fa3b6298c0dde54/68747470733a2f2f7472617669732d63692e6f72672f706c756d7068702f706c756d2d6373762e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/plumphp/plum-csv)[![Windows Build status](https://camo.githubusercontent.com/3805a33d91e95247477620d703aa9731b71f67db3ac279f6eb437d875b9236ee/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f633575367931686c743067326737396e3f7376673d74727565)](https://ci.appveyor.com/project/florianeckerstorfer/plum-csv)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/d50de5044923f7f5b0f5e05256945b3e46906ef471edf41444f3e80b7361cfdc/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f706c756d7068702f706c756d2d6373762f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/plumphp/plum-csv/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/f8ba1c33962433629c5f86b2e140c4a559e0cb33c19be4d56265a6f8960db6be/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f706c756d7068702f706c756d2d6373762f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/plumphp/plum-csv/?branch=master)[![StyleCI](https://camo.githubusercontent.com/15e65ee4651458e9041e70e7b0c05c9ef24d822d49435163b7855cbcd1b8c4d5/68747470733a2f2f7374796c6563692e696f2f7265706f732f33303236363435392f736869656c64)](https://styleci.io/repos/30266459)

Developed by [Florian Eckerstorfer](https://florian.ec) in Vienna, Europe.

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

[](#installation)

You can install Plum using [Composer](http://getcomposer.org).

```
$ composer require plumphp/plum-csv
```

Usage
-----

[](#usage)

Please refer to the [Plum documentation](https://github.com/plumphp/plum/blob/master/docs/index.md) for information about Plum in general.

Currently PlumCsv contains a reader and a writer for CSV files and uses [League\\CSV](https://github.com/thephpleague/csv) to actually read and write CSV files.

### `CsvReader`

[](#csvreader)

You can use the `Plum\PlumCsv\CsvReader` to read data from a `.csv` file.

```
use Plum\PlumCsv\CsvReader;

$reader = new CsvReader('countries.csv');
```

Optionally you can also pass the delimiter and enclosure to the constructor.

```
$reader = new CsvReader('countries.csv`, ',', '"');
```

Most CSV files have a header row. Because Plum processes a CSV file row by row you need to add `HeaderConverter` to change the index of each read item. In addition you can use the `SkipFirstFilter` to skip the header row. Both `HeaderConverter` and `SkipFirstFilter` are part of the core Plum package.

```
use Plum\Plum\Converter\HeaderConverter;
use Plum\Plum\Filter\SkipFirstFilter;

$workflow = new Workflow();
$workflow->addConverter(new HeaderConverter());
$workflow->addFilter(new SkipFirstFilter(1));
$reader = new CsvReader('countries.csv`, ',', '"');
```

### `CsvWriter`

[](#csvwriter)

The `Plum\PlumCsv\CsvWriter` allows you to write the data into a `.csv` file.

```
use Plum\PlumCsv\CsvWriter;

$writer = new CsvWriter('foobar.csv', ',', '"');
$writer->prepare();
$writer->writeItem(['value 1', 'value 2', 'value 3');
$writer->finish();
```

The second and third argument of `__construct()` are optional and by default `,` and `"` respectively. In addition the `setHeader()` method can be used to define the names of the columns. It has to be called before the `prepare()`.

```
$writer = new CsvWriter('foobar.csv');
$writer->setHeader(['column 1', 'column 2', 'column 3']);
$writer->prepare();
```

When you read data dynamically you probably don't want to set the header columns manually. You can call `autoDetectHeader()` to use the array keys of the first item written to `CsvWriter` as headers.

```
$writer = new CsvWriter('foobar.csv');
$writer->autoDetectHeader(); // Must be called before the first `writeItem()`
```

If you need to further configure the writer, you can inject an instance of `League\Csv\Writer` to `Plum\PlumCsv\CsvWriter`.

```
use Plum\PlumCsv\CsvWriter;
use League\Csv\Writer;

$csv = Writer::createFromFileObject(new SplFileObject('countries.csv', 'w'));
$csv->setNullHandlingMode(Writer::NULL_AS_EMPTY);
$writer = new CsvWriter($csv);
```

Change Log
----------

[](#change-log)

### Version 0.4 (28 October 2015)

[](#version-04-28-october-2015)

- Check if item is array before auto-setting header
- [\#10](https://github.com/plumphp/plum-csv/pull/10) Allow injection of `League\Csv\Writer`

### Version 0.3.1 (28 April 2015)

[](#version-031-28-april-2015)

- Fix Plum version

### Version 0.3 (22 April 2015)

[](#version-03-22-april-2015)

- Add support for ReaderFactory

### Version 0.2 (21 April 2015)

[](#version-02-21-april-2015)

- Fix Plum version

### Version 0.1 (24 March 2015)

[](#version-01-24-march-2015)

- Initial release

License
-------

[](#license)

The MIT license applies to plumphp/plum.json. For the full copyright and license information, please view the LICENSE file distributed with this source code.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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 ~27 days

Recently: every ~47 days

Total

9

Last Release

3855d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a80f9fc61cd3a7d7779e8f120b458ca4d18fdd885d719bb77d3379b96bf714d9?d=identicon)[florianeckerstorfer](/maintainers/florianeckerstorfer)

---

Top Contributors

[![Sgoettschkes](https://avatars.githubusercontent.com/u/628796?v=4)](https://github.com/Sgoettschkes "Sgoettschkes (9 commits)")[![florianeckerstorfer](https://avatars.githubusercontent.com/u/149201?v=4)](https://github.com/florianeckerstorfer "florianeckerstorfer (2 commits)")[![gries](https://avatars.githubusercontent.com/u/417823?v=4)](https://github.com/gries "gries (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/plumphp-plum-csv/health.svg)

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

###  Alternatives

[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

22.8k69.3k](/packages/grumpydictator-firefly-iii)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[craftcms/feed-me

Import content from XML, RSS, CSV or JSON feeds into entries, categories, Craft Commerce products, and more.

292927.5k22](/packages/craftcms-feed-me)[troydavisson/phrets

RETS library in PHP

463355.6k](/packages/troydavisson-phrets)[firefly-iii/data-importer

Firefly III Data Import Tool.

7545.8k](/packages/firefly-iii-data-importer)

PHPackages © 2026

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