PHPackages                             originphp/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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. originphp/csv

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

originphp/csv
=============

OriginPHP CSV

2.1.0(5y ago)247MITPHPPHP &gt;=7.3.0CI failing

Since Oct 11Pushed 5y ago1 watchersCompare

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

READMEChangelogDependencies (3)Versions (5)Used By (0)

CSV
===

[](#csv)

[![license](https://camo.githubusercontent.com/6fdb99389fe9d9e8a5c197002a191ace7c8b12a2020c0fa5756cf17aa08a4966/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874477265656e2e737667)](https://camo.githubusercontent.com/6fdb99389fe9d9e8a5c197002a191ace7c8b12a2020c0fa5756cf17aa08a4966/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874477265656e2e737667)[![build](https://github.com/originphp/csv/workflows/CI/badge.svg)](https://github.com/originphp/csv/actions)[![coverage](https://camo.githubusercontent.com/7b1114a502264b2b26a39c6909648ed5bc464a2618f5d9177901d92362fb0bf0/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6f726967696e7068702f6373762f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/originphp/csv?branch=master)

The CSV utility makes it easy to work with CSV files.

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

[](#installation)

To install this package

```
$ composer require originphp/csv

```

Create CSV from an Array
------------------------

[](#create-csv-from-an-array)

To use an array to create CSV data

```
use Origin\Csv\Csv;

$csv = Csv::fromArray([
    ['jim','jim@example.com'],
    ['tony','tony@example.com']
]);
```

Which will give you this

```
jim,jim@example.com
tony,tony@example.com

```

You can also use keys from the array as headers

```
use Origin\Csv\Csv;

$csv = Csv::fromArray([
        ['name'=>'jim','email'=>'jim@example.com'],
        ['name'=>'tony','email'=>'tony@example.com']
    ],['header'=>true]);
```

Which will return this

```
name,email
jim,jim@example.com
tony,tony@example.com

```

If you want to use custom headers

```
use Origin\Csv\Csv;

$csv = Csv::fromArray([
        ['name'=>'jim','email'=>'jim@example.com'],
        ['name'=>'tony','email'=>'tony@example.com']
    ],['header'=>['First Name','Email Address']]);
```

Which will gives you this

```
"First Name","Email Address"
jim,jim@example.com
tony,tony@example.com

```

Create an Array from CSV Data
-----------------------------

[](#create-an-array-from-csv-data)

Use the `toArray` method to create an array using CSV data.

```
use Origin\Csv\Csv;

$csv = file_get_contents('/path/file.csv');
$data = Csv::toArray($csv);
```

If the CSV file has a header row, then you can skip it by passing an options array with the key header set to true.

```
$data = Csv::toArray($csv,['header'=>true]);
```

If you want to use the headers as keys for each record in the array, this will use the first row as the keys for the array.

```
$data = Csv::toArray($csv,['header'=>true,'keys'=>true]);
```

If you want to set custom keys for each record in the array

```
$data = Csv::toArray($csv,['keys'=>['First Name','Email Address']]);
```

Processing Large Files
----------------------

[](#processing-large-files)

To process large CSV files in a memory efficient way use the `process` method, which takes the the same options as `toArray`. The difference here is that, it will reads the CSV file one line at a time, returns its for processing, then goes the next.

```
$rows = Csv::process('/path/to/file.csv',['keys'=>['First Name','Email Address']]);
foreach($rows as $row){
    ... do something
}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~183 days

Total

4

Last Release

1858d ago

Major Versions

1.0.1 → 2.0.02021-01-03

PHP version history (3 changes)1.0.0PHP ^7.2.0

1.0.1PHP &gt;=7.2.0

2.0.0PHP &gt;=7.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e8a821333d9c7b7bc2ad3d164d142f65cd3912dea78033d31f76b0f19ba8a0c?d=identicon)[originphp](/maintainers/originphp)

---

Top Contributors

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

---

Tags

csvoriginPHP

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[league/csv

CSV data manipulation made easy in PHP

3.5k166.1M646](/packages/league-csv)[rap2hpoutre/fast-excel

Fast Excel import/export for Laravel

2.3k24.9M47](/packages/rap2hpoutre-fast-excel)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.1k57.6M131](/packages/openspout-openspout)[goodby/csv

CSV import/export library

9555.6M23](/packages/goodby-csv)[sonata-project/exporter

Lightweight Exporter library

44920.9M35](/packages/sonata-project-exporter)

PHPackages © 2026

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