PHPackages                             michaelsharman/parsecsv - 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. michaelsharman/parsecsv

ActiveLibrary

michaelsharman/parsecsv
=======================

CSV data parser for PHP

0.4.5(11y ago)0144MITPHP

Since Jun 3Pushed 8y ago1 watchersCompare

[ Source](https://github.com/michaelsharman/parsecsv-for-php)[ Packagist](https://packagist.org/packages/michaelsharman/parsecsv)[ RSS](/packages/michaelsharman-parsecsv/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

parseCSV
========

[](#parsecsv)

### March 2017

[](#march-2017)

Forked to make PSR compatible.

\--

ParseCsv is an easy to use PHP class that reads and writes CSV data properly. It fully conforms to the specifications outlined on the on the [Wikipedia article](http://en.wikipedia.org/wiki/Comma-separated_values). It has many advanced features which help make your life easier when dealing with CSV data.

This library was originaly created in early 2007 by [jimeh](https://github.com/jimeh) due to the lack of built-in and third-party support for handling CSV data in PHP.

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

[](#installation)

Installation is easy using Composer. Include the following in your composer.json

```
"michaelsharman/parsecsv-for-php": "dev-master"

```

Features
--------

[](#features)

- ParseCsv is the only complete and fully featured CSV solution for PHP (as far as I know).
- Supports enclosed values, enclosed commas, double quotes and new lines.
- Automatic delimiter character detection.
- Sort data by specific fields/columns.
- Easy data manipulation.
- Basic SQL-like *conditions*, *offset* and *limit* options for filtering data.
- Error detection for incorrectly formatted input. It attempts to be intelligent, but can not be trusted 100% due to the structure of CSV, and how different programs like Excel for example outputs CSV data.
- Support for character encoding conversion using PHP's *iconv* function (requires PHP 5).
- Supports both PHP 4 &amp; 5.

Example Usage
-------------

[](#example-usage)

**General**

```
use ParseCsv\ParseCsv;

$csv = new ParseCsv('data.csv');
print_r($csv->data);
```

**Tab delimited, and encoding conversion**

```
use ParseCsv\ParseCsv;

$csv = new ParseCsv();
$csv->encoding('UTF-16', 'UTF-8');
$csv->delimiter = "\t";
$csv->parse('data.tsv');
print_r($csv->data);
```

**Auto-detect delimiter character**

```
use ParseCsv\ParseCsv;

$csv = new ParseCsv();
$csv->auto('data.csv');
print_r($csv->data);
```

**Modify data in a CSV file**

```
use ParseCsv\ParseCsv;

$csv = new ParseCsv();
$csv->sort_by = 'id';
$csv->parse('data.csv');
# "4" is the value of the "id" column of the CSV row
$csv->data[4] = array('firstname' => 'John', 'lastname' => 'Doe', 'email' => 'john@doe.com');
$csv->save();
```

**Add row/entry to end of CSV file**

*Only recommended when you know the extact structure of the file.*

```
use ParseCsv\ParseCsv;

$csv = new ParseCsv();
$csv->save('data.csv', array(array('1986', 'Home', 'Nowhere', '')), true);
```

**Convert 2D array to csv data and send headers to browser to treat output as a file and download it**

```
use ParseCsv\ParseCsv;

$csv = new ParseCsv();
$csv->output('movies.csv', $array, array('field 1', 'field 2'), ',');
```

Credits
-------

[](#credits)

- ParseCsv is based on the concept of [Ming Hong Ng](http://minghong.blogspot.com/)'s [CsvFileParser](http://minghong.blogspot.com/2006/07/csv-parser-for-php.html)class.

Contributors
------------

[](#contributors)

Please find a complete list on the project's [contributors](https://github.com/parsecsv/parsecsv-for-php/graphs/contributors) page.

License
-------

[](#license)

(The MIT license)

Copyright (c) 2014 Jim Myhrberg.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

26

—

LowBetter than 46% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

4310d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/de75b9060be0672c1640970db62f7c1f838a2fabcfe7edb7a20d416569c54195?d=identicon)[michaelsharman](/maintainers/michaelsharman)

---

Top Contributors

[![waknauss](https://avatars.githubusercontent.com/u/20912626?v=4)](https://github.com/waknauss "waknauss (36 commits)")[![jimeh](https://avatars.githubusercontent.com/u/39563?v=4)](https://github.com/jimeh "jimeh (17 commits)")[![michaelsharman](https://avatars.githubusercontent.com/u/663796?v=4)](https://github.com/michaelsharman "michaelsharman (4 commits)")[![Norcoen](https://avatars.githubusercontent.com/u/1840514?v=4)](https://github.com/Norcoen "Norcoen (4 commits)")[![repat](https://avatars.githubusercontent.com/u/516807?v=4)](https://github.com/repat "repat (2 commits)")[![helpse](https://avatars.githubusercontent.com/u/1523409?v=4)](https://github.com/helpse "helpse (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/michaelsharman-parsecsv/health.svg)

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

PHPackages © 2026

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