PHPackages                             cocur/arff - 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. cocur/arff

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

cocur/arff
==========

v0.2.3(7y ago)71152MITPHP

Since Jul 17Pushed 3y ago1 watchersCompare

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

READMEChangelog (5)Dependencies (4)Versions (7)Used By (0)

cocur/arff
==========

[](#cocurarff)

> Read and write `.arff` files for Weka.

[![Build Status](https://camo.githubusercontent.com/5329b7a37544259a4e0a4f3e649d2ffebb2e526565fc67b2c8f64ac4b13c952c/68747470733a2f2f7472617669732d63692e6f72672f636f6375722f617266662e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/cocur/arff)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/73a8c462e57145c06423f5111e11bbf49e4706baa2cad0a9cd090e1c0d41a3ea/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f6375722f617266662f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/cocur/arff/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/85203e78a31da0909c94933ae0c05dde4f80fcf7b6d869f3b2b8dbcf3b84728e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f6375722f617266662f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/cocur/arff/?branch=master)

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

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

[](#installation)

You can install `cocur/arff` with [Composer](http://getcomposer.org):

```
$ composer require cocur/arff
```

Usage
-----

[](#usage)

### Write `.arff` file

[](#write-arff-file)

```
use Cocur\Arff\Document;
use Cocur\Arff\Column\NumericColumn;
use Cocur\Arff\Column\NominalColumn;

$document = new Document('iris');
$document->addColumn(new NumericColumn('sepallength'));
$document->addColumn(new NumericColumn('sepalwidth'));
$document->addColumn(new NumericColumn('petallength'));
$document->addColumn(new NumericColumn('petalwidth'));
$document->addColumn(new NominalColumn('class', ['Iris-setosa','Iris-versicolor','Iris-virginica']));

$document->addData(['sepallength' => 5.1, 'sepalwidth' => 3.5, 'petallength' => 1.4, 'petalwidth' => 0.2, 'class' => 'Iris-setosa']);

$writer = new Writer();

$writer->render($document);           // returns rendered .arff file
$writer->write($document, 'iris.arff'); // writes .arff file to disk
```

### Read `.arff` file

[](#read-arff-file)

```
use Cocur\Arff\Reader;

$reader = new Reader();
$document = $reader->readFile('irif.arff'); // returns Cocur\Arff\Document
```

#### Available types of columns

[](#available-types-of-columns)

- `Cocur\Arff\Column\NumericColumn`
- `Cocur\Arff\Column\StringColumn`
- `Cocur\Arff\Column\NominalColumn`
- `Cocur\Arff\Column\DateColumn`

#### Date columns

[](#date-columns)

You can define the date format for date columns. The format is only used to write to the Arff file, you need to convert the date manually before adding the data.

```
$column = new DateColumn('created', 'yyyy-MM-dd HH:mm:ss');
```

### Plum Integration

[](#plum-integration)

cocur/arff contains a writer for [Plum](https://github.com/plumphp/plum).

```
use Cocur\Arff\Bridge\Plum\ArffWriter;

$writer = new ArffWriter('filename.arff', 'name', [
    new NumericColumn('sepallength'),
    new NumericColumn('sepalwidth'),
    new NumericColumn('petallength'),
    new NumericColumn('petalwidth'),
    new NominalColumn('class', ['Iris-setosa','Iris-versicolor','Iris-virginica']),
]);
```

Changelog
---------

[](#changelog)

### Version 0.2.3 (7 September 2018)

[](#version-023-7-september-2018)

- [\#3](https://github.com/cocur/arff/pull/3) Support more generic relation name and drops malformed lines (by [frantzmiccoli](https://github.com/frantzmiccoli))

### Version 0.2.2 (16 March 2018)

[](#version-022-16-march-2018)

- Case-insensitive parsing of column type

### Version 0.2.1 (2 September 2017)

[](#version-021-2-september-2017)

- Fix parsing of nominal columns

### Version 0.2 (2 September 2017)

[](#version-02-2-september-2017)

- Split `ArffFile` into `Cocur\Arff\Document` and `Cocur\Arff\Writer`
- Add `Cocur\Arff\Reader` to read `.arff` files

### Version 0.1 (17 July 2015)

[](#version-01-17-july-2015)

- Initial release

License
-------

[](#license)

The MIT license applies to cocur/arff. 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

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.9% 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 ~519 days

Recently: every ~454 days

Total

6

Last Release

1364d ago

### Community

Maintainers

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

---

Top Contributors

[![florianeckerstorfer](https://avatars.githubusercontent.com/u/149201?v=4)](https://github.com/florianeckerstorfer "florianeckerstorfer (10 commits)")[![juliardi](https://avatars.githubusercontent.com/u/4223302?v=4)](https://github.com/juliardi "juliardi (2 commits)")[![frantzmiccoli](https://avatars.githubusercontent.com/u/2973447?v=4)](https://github.com/frantzmiccoli "frantzmiccoli (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cocur-arff/health.svg)

```
[![Health](https://phpackages.com/badges/cocur-arff/health.svg)](https://phpackages.com/packages/cocur-arff)
```

PHPackages © 2026

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