PHPackages                             foued611/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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. foued611/parsecsv

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

foued611/parsecsv
=================

CSV data parser for PHP

v2.0.1(11y ago)021MITPHP

Since Sep 16Pushed 11y ago1 watchersCompare

[ Source](https://github.com/foued611/parsecsv)[ Packagist](https://packagist.org/packages/foued611/parsecsv)[ RSS](/packages/foued611-parsecsv/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

parseCSV
========

[](#parsecsv)

[![](https://camo.githubusercontent.com/f903a58f801f8238c50b7a31acad98e158c0bae8d616afe617b5b8b99a7c5306/68747470733a2f2f7472617669732d63692e6f72672f666f7565643631312f70617273656373762e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/foued611/parsecsv)

Note: parseCSV is now being revised to PHP 5 standards. If you have an issue or a feature request we encourage you to open an issue.

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/foued611) due to the lack of built-in and third-party support for handling CSV data in PHP.

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

[](#installation)

**Installation using Composer.**

*Include the following in your composer.json*

```
 "foued611/parsecsv": "dev-master"

```

**psr-0 namespace autoloading.**

```
use Parse\Csv\ParseCSV;
```

*You may also manually include the ParseCSV.php file*

```
require_once ('parsecsv/src/Parse/Csv/ParseInterface.php');
require_once ('parsecsv/src/Parse/csv/ParseCSV.php');
```

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.4).
- Supports both PHP 5.4

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

[](#example-usage)

**General**

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

**Tab delimited, and encoding conversion**

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

**Auto-detect delimiter character**

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

**Modify data in a CSV file**

```
$csv = new \Parse\Csv\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 sctructure of the file.*

```
$csv = new ParseCSV();
$csv->save('data.csv', 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**

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

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

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 59% 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 ~0 days

Total

2

Last Release

4256d ago

### Community

Maintainers

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

---

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 (15 commits)")[![foued611](https://avatars.githubusercontent.com/u/1544132?v=4)](https://github.com/foued611 "foued611 (6 commits)")[![Norcoen](https://avatars.githubusercontent.com/u/1840514?v=4)](https://github.com/Norcoen "Norcoen (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M345](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

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