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

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

nathanielrich/csv
=================

Simple CSV class to handle csv-files import and export with delimiters, enclosures, escapes, charset, etc...

011PHP

Since Mar 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/nathanielrich/csv)[ Packagist](https://packagist.org/packages/nathanielrich/csv)[ RSS](/packages/nathanielrich-csv/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

NRich\\CSV
==========

[](#nrichcsv)

A simple universal package to easily generate or import CSV files.

### Installation

[](#installation)

Just run this on your terminal (project dir)

```
composer require nathanielrich/csv:@dev

```

that´s it.

Export
------

[](#export)

### Basic usage (download)

[](#basic-usage-download)

```
$data = [
    [
        'price' => 15.99,
        'name' => 'My Product',
        'availableAt' => '2015-01-16'
    ]
];

$csvExport = new NRich\CSV\Export();
$csvExport->build($data)
    ->download();
```

And a proper CSV file will be downloaded with headers of `$data` index.

### Basic usage (save as file)

[](#basic-usage-save-as-file)

```
$data = [
    [
        'price' => 15.99,
        'name' => 'My Product',
        'availableAt' => '2015-01-16'
    ]
];

$csvExport = new NRich\CSV\Export();
$csvExport->build($data)
    ->save('__PATH__TO__TARGET__FILE');
```

And a proper CSV file will be created at your path with headers of `$data` index.

### Basic usage (get raw data)

[](#basic-usage-get-raw-data)

```
$data = [
    [
        'price' => 15.99,
        'name' => 'My Product',
        'availableAt' => '2015-01-16'
    ]
];

$csvExport = new NRich\CSV\Export();
$csvExport->build($data)
    ->getRawData('__PATH__TO__TARGET__FILE');
```

Will return a string with csv-file-data.

### Basic usage (symfony/laravel UploadedFile)

[](#basic-usage-symfonylaravel-uploadedfile)

```
$data = [
    [
        'price' => 15.99,
        'name' => 'My Product',
        'availableAt' => '2015-01-16'
    ]
];

$csvExport = new NRich\CSV\Export();
$csvExport->build($data)
    ->getSymfonyUploadedFile('__PATH__TO__TARGET__FILE');
```

Will return the class UploadedFile of symfony´s http-foundation library.

### Usage with non custom-indexed array

[](#usage-with-non-custom-indexed-array)

```
$data = [
    [
        15.99,
        'My Product',
        '2015-01-16'
    ]
];

$csvExport = new NRich\CSV\Export();
$csvExport->build($data, [
    'price', 'name', 'availableAt'
])
    ->download();
```

### Windows/Excel defaults

[](#windowsexcel-defaults)

At the current version of excel or other windows based software solutions. They expect an `;` instead of the standard `,`.

You can do customize it at the constructor:

```
$data = [
    [
        15.99,
        'My Product',
        '2015-01-16'
    ]
];

$csvExport = new NRich\CSV\Export(';');
...
```

Or you can choose the predefined windows option:

```
$data = [
    [
        15.99,
        'My Product',
        '2015-01-16'
    ]
];

$csvExport = new NRich\CSV\Export();
$csvExport->windows()
    ->build($data)
    ->download();
...
```

Import
------

[](#import)

### Basic usage

[](#basic-usage)

```
$csvImport = new NRich\CSV\Import();
$data = $csvImport->execute('__PATH__TO__YOUR__FILE');

print_r($data);
```

will return an array of objects from your csv file. if you wanna have an nested array instead of object you can set the second param of execute() to `true`.

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

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/7a93cebd760fd3e511c6ac694d30cf6c8ddea7d030074e8251de170c9983323a?d=identicon)[nathanielrich](/maintainers/nathanielrich)

---

Top Contributors

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

### Embed Badge

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

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

PHPackages © 2026

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