PHPackages                             heller/simple-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. [File &amp; Storage](/categories/file-storage)
4. /
5. heller/simple-csv

ActiveLibrary[File &amp; Storage](/categories/file-storage)

heller/simple-csv
=================

A package to make working with CSV files as convenient and simple as possible

053[1 PRs](https://github.com/lpheller/simple-csv/pulls)PHP

Since May 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/lpheller/simple-csv)[ Packagist](https://packagist.org/packages/heller/simple-csv)[ RSS](/packages/heller-simple-csv/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (2)Used By (0)

Simple CSV
==========

[](#simple-csv)

Make dealing with CSV data as easy and comfortable as possible.

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

[](#installation)

```
composer require heller/simple-csv
```

Usage
-----

[](#usage)

### Basic array

[](#basic-array)

```
use Heller\SimpleCsv\Csv;

$csv = Csv::read('filepath.csv')->toArray();

$csv = Csv::read('http://urlto.csv')->toArray();
```

### Header mapping

[](#header-mapping)

Assuming that you have a csv table where the first row holds the cullum names using the `mapToHeader` function makes handling the data much easier.

```
use Heller\SimpleCsv\Csv;

$csv = Csv::read('filepath.csv')
            ->mapToHeaders()
            ->toArray();

foreach($csv as $row){
    echo $row['columnname']; // instead of using $row[3]
}
```

### Skipping rows &amp; columns

[](#skipping-rows--columns)

Sometimes it can be helpful to skip certain rows or columns. You can do that using `skipRows` and `skipColumns` methods.

```
$csv = Csv::read('filepath.csv')
           ->skipRows(1)
           ->skipColumns([2, 4, 'columnname'])
           ->toArray();
```

Both methods accept either an `int` for a certain row / column or `array` to skip multiple rows or columns. The `skipColumns` method also accepts column (header) names as input.

### Filtering

[](#filtering)

As the csv data is just array, we can of course filter the data however you like. For convenience we can also filter while collecting the data using the filter() callback.

```
$csv = Csv::read('filepath.csv')
           ->filter(fn($row) => $row['column'] != 'foo')
           ->toArray();
```

### Map to object

[](#map-to-object)

Mapping rows to objects allows you to work with CSV data in a more structured way. By default the rows are mapped to `stdClass` which allows to access the CSV data using object properties.

However, if you specify a custom class each row will be mapped to the class based on the header column names.

```
// ...

$csv->mapToObject(); // Maps rows to stdClass

$csv->mapToObject(CsvRow::class)
    ->filter(function(CsvRow $item){
        return $item->isValid();
    })
    ->toArray();
```

When using the mapToObject method, the column headers slightly adjusted so the object properties are ensured to have valid names. If a column header was named "Starts At", the name will be normalized to "starts\_at" so it can be accessed with `$row->starts_at`. For custom class mapping the (normalized) column header has to match the class property name.

### Individually process row

[](#individually-process-row)

The `get` method will allways return an of rows from the csv file. Either as arrays or object. However, while being handy for smaller tasks, this is not memory efficient and can cause problems with large csv files. To solve this, you can process each row individually and still let the package solve the mapping, filtering and skipping etc. This even makes handling large files with millions of records as simple as possible.

```
$csv->mapToObject(CsvRow::class)
    ->each(function(CsvRow $item) {
        // ... import the data or handle the data however you like
    });
```

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/08323ca76e33bcc68a88d7e3b77b248c349e840bc50b33bf3f7610687532a774?d=identicon)[lpheller](/maintainers/lpheller)

---

Top Contributors

[![lpheller](https://avatars.githubusercontent.com/u/36259611?v=4)](https://github.com/lpheller "lpheller (4 commits)")

### Embed Badge

![Health badge](/badges/heller-simple-csv/health.svg)

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

PHPackages © 2026

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