PHPackages                             pfuri/awesome-php-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. [Database &amp; ORM](/categories/database)
4. /
5. pfuri/awesome-php-csv

ActiveLibrary[Database &amp; ORM](/categories/database)

pfuri/awesome-php-csv
=====================

AwesomePHPCSV is a simple, fast &amp; lightweight CSV parser built for PHP 5.3+

v2.1.1(9y ago)4282MITPHPPHP &gt;=5.3.0

Since Mar 6Pushed 9y ago1 watchersCompare

[ Source](https://github.com/pfuri/awesome-php-csv)[ Packagist](https://packagist.org/packages/pfuri/awesome-php-csv)[ Docs](https://github.com/pfuri/awesome-php-csv)[ RSS](/packages/pfuri-awesome-php-csv/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)DependenciesVersions (6)Used By (0)

awesome-php-csv
===============

[](#awesome-php-csv)

AwesomePHPCSV is a simple, fast &amp; lightweight CSV parser built for PHP 5.3+

Breaking Changes in 2.1
=======================

[](#breaking-changes-in-21)

**1.** `hasHeadingRow` parameter has been renamed to `skipHeaderRow` which is what it actually does

**2.** `mapColumns` parameter has been added to use the values from the first row as associative array keys for the rest of the rows in the returned results *(may lower performance)*

Usage
=====

[](#usage)

AwesomePHPCSV is simple and easy to use. Just follow the instructions below:

**1.** include AwesomePHPCSV into your own PHP project via Composer.

From the command line:

```
composer require pfuri/awesomephp-csv:~2.1

```

Or in your composer.json file add pfuri/awesome-php-csv to the list of required packages and then run `composer update`:

```
{
    ...
    "require": {
        ...
        "pfuri/awesome-php-csv": "~2.1",
        ...
    }
    ...
}
```

**2.** create an AwesomePHPCSV instance:

```
use pfuri\AwesomePHPCSV;

$apcsv = new AwesomePHPCSV();
```

***Having trouble? Don't forget to include the Composer autoload.php file!"***

```
require __DIR__ . '/vendor/autoload.php';
```

**3.** create an options array (see options section below for a full set of options):

```
$options = array(
    'pathToFile' => 'example.csv',
    'hasHeaderRow' => true
);
```

**4.** call the import function the CSV into a PHP array:

```
$data = $apcsv->import($options);
if($data === false) {
    // false means there was some kind of error
    // error messages can be found in the error message array
    $errorMessages = $apcsv->errorMessages;
    print_r($errorMessages);
}
```

The result is now a PHP array with each row representing a row from the CSV file (see the result format section below for an example)

Import Options
==============

[](#import-options)

Below is the complete list of options for ***AwesomePHPCSV::import(array $options)***:

- *string **pathToFile** (required)*: The full path to the csv file to be parsed *(note: if ***file*** is used instead of ***pathToFile***, then ***pathToFile*** is not required)*
- *string **file** (optional)*: The CSV file in array format, where each row of the CSV is a string in the array *(note: must not include line endings)*
- *boolean **skipHeaderRow** (optional) (default: false)*: Whether or not to skip the first row
- *boolean **mapColumns** (optional) (default: false)*: use the values from the first row as associative array keys for the rest of the rows in the returned results *(may lower performance)*
- *int **columns** (optional) (default: null)*: Enables column validation by specifying how many the columns each row should have. If the csv contains a row without exactly this many columns, import will fail
- *int **start** (optional) (default:1)*: The row to start on \[inclusive\]
- *int **end** (optional) (default:null)*: The row to end on \[inclusive\]
- *int **loopLimit** (optional) (default:100)*: The amount of time to spend parsing a single row. You shouldn't need to change this
- *boolean **debug** (optional) (default:false)*: Prints error messages using debug() if any are encountered

Result Format
=============

[](#result-format)

If this is your CSV file:

> Year, Make, Model, Color

> 2016, Cadillac, Escalade, Black

> 2016, Mercedes Benz, ML350, Black

Then after importing, you would receive a PHP array that looks like:

```
[
    [2016, Cadillac, Escalade, Black],
    [2016, Mercedes Benz, ML350, Black]
]
```

Example File
============

[](#example-file)

*example.php* will import *example.csv* and output the results.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Total

5

Last Release

3347d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

phpdatabaseexcelcsvspreadsheetimportlistdbdelimitedtablevalueawesomecomma

### Embed Badge

![Health badge](/badges/pfuri-awesome-php-csv/health.svg)

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

###  Alternatives

[ddeboer/data-import

Import data from, and export data to, a range of file formats and media

5604.3M9](/packages/ddeboer-data-import)[rah/danpu

Zero-dependency MySQL dump library for easily exporting and importing databases

64401.8k10](/packages/rah-danpu)[archon/dataframe

Archon: PHP Data Analysis Library

9824.2k1](/packages/archon-dataframe)[tomatophp/filament-translations

Manage your translation with DB and cache, you can scan your languages tags like trans(), \_\_(), and get the string inside and translate them use UI.

6230.1k3](/packages/tomatophp-filament-translations)[jawira/db-draw

📐 Takes a DoctrineORM connection and generates a database diagram in .puml format

2295.1k2](/packages/jawira-db-draw)[webparking/laravel-db-rebuild

A laravel package that allows for quick database rebuilds with presets.

448.8k](/packages/webparking-laravel-db-rebuild)

PHPackages © 2026

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