PHPackages                             lianhua/supercsv - 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. lianhua/supercsv

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

lianhua/supercsv
================

A simple PHP library for CSV reading and writing

1.0.1(6y ago)024GPL-3.0PHPPHP &gt;=7.3

Since Apr 24Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Nevermille/PHP-SuperCSV)[ Packagist](https://packagist.org/packages/lianhua/supercsv)[ RSS](/packages/lianhua-supercsv/feed)WikiDiscussions master Synced 6d ago

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

PHP SuperCSV
============

[](#php-supercsv)

A little library for CSV reading and writing in PHP

[![Build Status](https://camo.githubusercontent.com/472745aff500e91ca4f8a7da7616051af705ef96751367fc80ae5599310e3fd5/68747470733a2f2f7472617669732d63692e636f6d2f4e657665726d696c6c652f5048502d53757065724353562e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/Nevermille/PHP-SuperCSV) [![BCH compliance](https://camo.githubusercontent.com/cd460b7617c1e526aee1bf14aad4e632c5dba1ef817e88c8e6803ab8102a69ed/68747470733a2f2f626574746572636f64656875622e636f6d2f656467652f62616467652f4e657665726d696c6c652f5048502d53757065724353563f6272616e63683d6d6173746572)](https://bettercodehub.com/) [![License: GPL v3](https://camo.githubusercontent.com/48bf9b56d44f38db53ce21294cf0b9487d0a3734ab3ba1fe4c69858ae20db2c1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c76332d626c75652e737667)](https://www.gnu.org/licenses/gpl-3.0)

Overview
--------

[](#overview)

A simple PHP library for reading and writing CSV files.

Compatibility
-------------

[](#compatibility)

This library has been tested for PHP 7.3 and higher

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

[](#installation)

Just use composer in your project:

```
composer require lianhua/supercsv

```

If you don't use composer, clone or download this repository, all you need is inside the src directory.

Usage
-----

[](#usage)

### Read a CSV file

[](#read-a-csv-file)

#### Raw data

[](#raw-data)

Let's say we have the following CSV file:

```
A,B,C,D
E,F,G,H

```

Create a new Reader and then, you can read line by line with the read method:

```
$csv = new \Lianhua\SuperCSV\Reader("/path/to/csv");
$csv->read(); // ["A", "B", "C", "D"]
$csv->read(); // ["E", "F", "G", "H"]
```

You also can read the entire file at once with the readAll method:

```
$csv = new \Lianhua\SuperCSV\Reader("/path/to/csv");
$csv->readAll(); // [["A", "B", "C", "D"], ["E", "F", "G", "H"]]
```

By default, the reader considers the file as comma separated, you can change the format directly with the constructor along with enclosure and escape chars:

```
$csv = new \Lianhua\SuperCSV\Reader("/path/to/csv", ";", "'", "!");
```

#### With header

[](#with-header)

If your csv has a header, make sure to call the getHeader method. The reader will create an assoc array when reading.

CSV file:

```
English,French
Apple,Pomme
Pear,Poire

```

Reading:

```
$csv = new \Lianhua\SuperCSV\Reader("/path/to/csv");
$csv->getHeader();
$csv->read(); // ["English" => "Apple", "French" => "Pomme"]
$csv->read(); // ["English" => "Pear", "French" => "Poire"]
```

### Write a CSV file

[](#write-a-csv-file)

#### Raw data

[](#raw-data-1)

Create a Writer and use the write method:

```
$csv = new \Lianhua\SuperCSV\Writer("/path/to/csv");
$csv->write(["A", "B", "C", "D"]);
$csv->write(["E", "F", "G", "H"]);
```

You'll get this CSV file:

```
A,B,C,D
E,F,G,H

```

You can write all data at once with the writeAll method:

```
$csv = new \Lianhua\SuperCSV\Writer("/path/to/csv");
$csv->writeAll([["A", "B", "C", "D"], ["E", "F", "G", "H"]]);
```

By default, the writer will overwrite the file, if you want to append instead, give false in second constructor's parameter:

```
$csv = new \Lianhua\SuperCSV\Writer("/path/to/csv", false);
```

Of course, you can change the format as well:

```
$csv = new \Lianhua\SuperCSV\Writer("/path/to/csv", true, ";");
$csv->write(["A", "B", "C", "D"]);
$csv->write(["E", "F", "G", "H"]);
```

You'll get this CSV file:

```
A;B;C;D
E;F;G;H

```

#### With header

[](#with-header-1)

You can write csv with header with the setHeader method. You can give assoc arrays after that:

```
$csv = new \Lianhua\SuperCSV\Reader("/path/to/csv");
$csv->setHeader(["English", "French"]);
$csv->write(["English" => "Apple", "French" => "Pomme"]);
$csv->write(["French" => "Poire", "English" => "Pear"]);
```

You'll get this CSV file:

```
English,French
Apple,Pomme
Pear,Poire

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Total

2

Last Release

2215d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/38858480?v=4)[Camille Nevermind](/maintainers/Nevermille)[@nevermille](https://github.com/nevermille)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/lianhua-supercsv/health.svg)

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

PHPackages © 2026

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