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

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

unicframework/csv-parser
========================

CSVParser parse csv data to array, object, and json.

v1.1.1(5y ago)31.1kMITPHPPHP &gt;=5.6

Since Feb 17Pushed 5y ago1 watchersCompare

[ Source](https://github.com/unicframework/csv-parser)[ Packagist](https://packagist.org/packages/unicframework/csv-parser)[ Docs](https://unicframework.github.io/csv-parser)[ RSS](/packages/unicframework-csv-parser/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (4)DependenciesVersions (4)Used By (0)

CSVParser
---------

[](#csvparser)

 [![Unic Logo](logo.jpg)](logo.jpg)

CSVParser library parse csv data to array, object, and json format. CSVParser convert array, object, json to csv format.

### Features

[](#features)

- Parse data from csv file, array, json and objects.
- Parse csv to array and array to csv.
- Parse csv to object and object to csv.
- Parse csv to json and json to csv.
- Set custom headers to csv file.

### Installation

[](#installation)

- Install `composer` if you have not installed.

```
composer require unicframework/csv-parser
```

### Parse Data

[](#parse-data)

```
use CSVParser\CSV;

$csv = new CSV();

//Parse data from csv file
$csv->parse('data.csv');

//Parse array data
$csv->parse($arrayData);

//Parse object data
$csv->parse($jsonData);

//Parse json data
$csv->parse($objectData);
```

### Get Parsed Data

[](#get-parsed-data)

```
//Get header
$header = $csv->getHeader();

//Get parsed data to array format
$data = $csv->toArray();

//Select data from parsed data
$data = $csv->toArray(['Name', 'Email']);

//Get parsed data to object format
$data = $csv->toObject();

//Select data from parsed data
$data = $csv->toObject(['Name', 'Email']);

//Get parsed data to json format
$data = $csv->toJson();

//Select data from parsed data
$data = $csv->toJson(['Name', 'Email']);

//Get parsed data to csv format
$data = $csv->toCsv();

//Select data from parsed data
$data = $csv->toCsv(['Name', 'Email']);
```

### Get Row Count

[](#get-row-count)

```
//Get row count
$rows = $csv->rowCount();

//Get header count
$cols = $csv->headerCount();
```

### Select Data Limit

[](#select-data-limit)

```
//Select 10 records
$csv->limit(10);
$data = $csv->toArray();

//Select from 5 to 10 records
$csv->limit(5, 10);
$data = $csv->toArray();
```

### Set CSV Header

[](#set-csv-header)

```
//Ignore header from csv file
$csv->ignoreHeader(true);

//Ignore csv header cse
$csv->ignoreHeaderCase(true);

//Ignore csv enclosure
$csv->ignoreEnclosure(true);

//Set header offset of csv file
$csv->headerOffset(0);

//Set custom header to csv file
$csv->setHeader(['Name', 'Email']);
```

### Set CSV Delimiter

[](#set-csv-delimiter)

Default csv delimiter is `,` but we can set other delimiter for csv file.

```
//Set delimiter
$csv->setDelimiter('|');

//Set enclosure
$csv->setEnclosure('"');

//Set escape character
$csv->setEscape('//');

//Parse csv file data
$csv->parse('data.csv');

//Get data from parsed data
$data = $csv->toArray();
```

### Aggregate Functions

[](#aggregate-functions)

```
//Parse csv file data
$csv->parse('data.csv');

//Get total sum of given field
$total_price = $csv->sum('price');

//Get minimum from given field
$min_price = $csv->min('price');

//Get maximum from given field
$max_price = $csv->max('price');

//Get average of given field
$average_price = $csv->average('price');
```

License
-------

[](#license)

[MIT License](https://github.com/unicframework/csv-parser/blob/main/LICENSE)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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 ~42 days

Total

3

Last Release

1867d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/32831684?v=4)[Rajkumar Dusad](/maintainers/rajkumardusad)[@rajkumardusad](https://github.com/rajkumardusad)

---

Top Contributors

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

---

Tags

csv-exportcsv-importcsv-parsercsv-to-arraycsv-to-jsoncsvparserphp-csvcsv to jsoncsv parsercsv to arrayCSVParsercsv to object

### Embed Badge

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

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

PHPackages © 2026

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