PHPackages                             johnnyfreeman/coseva - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. johnnyfreeman/coseva

AbandonedArchivedLibrary[Parsing &amp; Serialization](/categories/parsing)

johnnyfreeman/coseva
====================

A friendly, object-oriented library for parsing and filtering CSV files with PHP.

81216.3k—5.5%16[5 issues](https://github.com/johnnyfreeman/coseva/issues)PHP

Since Aug 10Pushed 12y ago6 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

[![Coseva](https://camo.githubusercontent.com/104fdffdba407a341ae76eb65f67ceab306d5f5e02d98dd69139e80a6505c929/687474703a2f2f636f736576612e73332e616d617a6f6e6177732e636f6d2f6c6f676f2e706e67 "Coseva")](https://camo.githubusercontent.com/104fdffdba407a341ae76eb65f67ceab306d5f5e02d98dd69139e80a6505c929/687474703a2f2f636f736576612e73332e616d617a6f6e6177732e636f6d2f6c6f676f2e706e67)

A friendly, object-oriented library for parsing and filtering CSV files with [PHP](http://www.php.net/).

[![Screenshot](https://camo.githubusercontent.com/8b845d41c870caee10a8a8221455f55abca058c37257a08aacc30342500864ff/687474703a2f2f636f736576612e73332e616d617a6f6e6177732e636f6d2f656469746f722e706e67)](https://camo.githubusercontent.com/8b845d41c870caee10a8a8221455f55abca058c37257a08aacc30342500864ff/687474703a2f2f636f736576612e73332e616d617a6f6e6177732e636f6d2f656469746f722e706e67)

This (above) is an example of how to use Coseva in the simplest form. However, it is much more capable than this. :)

What is it?
===========

[](#what-is-it)

Coseva (pronounced co•see•vah) is an abstraction library for making `.csv` files easier to work with. But what makes it special is it allows you to have a clean [separation of concerns](http://en.wikipedia.org/wiki/Separation_of_concerns) in your data-filtering logic. This is one of the main points of Coseva, to give the developer the ability to keep unrelated logic separate from each other. In many cases, all data-filtering logic is contained in one big loop. This "spaghetti code" leads to a codebase that is increasingly difficult to maintain and update, and near impossible to read months later when you come back to it. But by breaking down your logic into smaller distinct chunks (Coseva calls these chunks "[filters](https://github.com/johnnyfreeman/coseva#filter-column-callable-)"), you can avoid many of the headaches that come with the everything-in-one-giant-loop approach.

Installation
============

[](#installation)

The recommended way to install Coseva is through [composer](http://getcomposer.org/). Just create a composer.json file and run the `composer install` command to install it:

```
{
    "minimum-stability": "dev",
    "require": {
        "johnnyfreeman/coseva": "*"
    }
}
```

Or, you can download the [coseva.zip](https://github.com/johnnyfreeman/coseva/zipball/master) file and extract it.

Getting Started
===============

[](#getting-started)

There are a few things you should know before diving in.

The first thing, is that Coseva doesn't do anything other than parse a csv, and give you the results; no querying a database, no jumping on one foot, etc. That's left up to you.

The second thing is the order in which filters are run. The parser loops through the csv file, line by line, from top to bottom, and at each line it runs all filters in the same order they were registered in.

So if we were to register two filters like this:

```
