PHPackages                             coercive/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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. coercive/csv

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

coercive/csv
============

Coercive Utility Csv

0.0.14(5mo ago)11.8kMITPHPPHP &gt;=7.4

Since May 25Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/Coercive/Csv)[ Packagist](https://packagist.org/packages/coercive/csv)[ Docs](http://coercive.fr)[ RSS](/packages/coercive-csv/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (15)Used By (0)

Coercive Csv
============

[](#coercive-csv)

- The CSV Importer allows you to easily import CSV files by parsing them to array with setted labels.
- The CSV Exporter allows you to easily export array to CSV files.

Get
---

[](#get)

```
composer require coercive/csv

```

IMPORTER
--------

[](#importer)

```
use Coercive\Utility\Csv\Importer;

# INIT CSV OBJECT
$csv = new Importer('path/name.csv');

# AUTO DETECT DELIMITER
$csv->detectDelimiter(int test nb line : 10 , array delimiter test list [';', ',']);

# OFFSET SEEK LINE (from start or current position)
$csv->seek(5, true|false);

# PARSE HEADER
$csv->parseHeader();

# CUSTOM CELLS NAME
$csv->setHeader([
    'cell_name_1',
    'cell_name_2',
    'cell_name_3',
    'cell_name_4',
    ...
]);

# YOU CAN SPECIFY TO NOT RETRIEVE OPTIONAL CELLS BY SETTING NULL
$csv->setHeader([
    'cell_name_1',
    NULL,
    'cell_name_3',
    NULL,
    ...
]);

# GET CSV TO ARRAY
$array = $csv->get();

# CUSTOM CELL PROCESS
$csv->callback(function($value, $cellKey, $currentLine) {

	/**
	 * Receive 3 arguments :
	 * function( (string) $value , (string) $cellKey , (int) $currentLine )
	 *
	 * The cellKey is allways a string, even if numeric column name (for strict compare)
	 *
	 * Your callable should return the processed value of the current cell
	 */

	return "Line : $currentLine, cell : $cellKey, value : $value";
});
```

EXPORTER
--------

[](#exporter)

```
use Coercive\Utility\Csv\Exporter;

# INIT CSV OBJECT (csv, tsv etc...)
$csv = new Exporter('/path/to/csv/file.csv');

# OPTIONS
$csv = new Exporter('/path/to/csv/file.csv', delimiter : ',', enclosure : '"', mysqlnull false);

# HEADER [optional]
$csv->addHeader(['name_col_1', 'name_col_2', 'name_col_3' ... ]);

# SAVE ONE LINE
foreach(x as y) $csv->addLine(['col_1', 'col_2', 'col_3' ... ]);

# SAVE MULTIPLE LINES
$csv->addLines([
    ['col_1', 'col_2', 'col_3' ... ],
    ['col_1', 'col_2', 'col_3' ... ],
    ['col_1', 'col_2', 'col_3' ... ],
    ['col_1', 'col_2', 'col_3' ... ]
    ...
]);

# CLOSE MANUALLY OR AUTO
$csv->close();
# OR
unset($csv);
```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance70

Regular maintenance activity

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

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

Recently: every ~288 days

Total

14

Last Release

176d ago

PHP version history (3 changes)0.0.1PHP &gt;=7

0.0.4PHP &gt;=7.1

0.0.13PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20288080?v=4)[Coercive](/maintainers/Coercive)[@Coercive](https://github.com/Coercive)

---

Top Contributors

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

---

Tags

csvphp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M102](/packages/spatie-browsershot)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.2k57.6M131](/packages/openspout-openspout)[keboola/csv

Keboola CSV reader and writer

1451.8M21](/packages/keboola-csv)[setasign/tfpdf

This class is a modified version of FPDF that adds UTF-8 support. The latest version is based on FPDF 1.85.

426.1M30](/packages/setasign-tfpdf)[aspera/xlsx-reader

Spreadsheet reader library for XLSX files

52742.2k5](/packages/aspera-xlsx-reader)

PHPackages © 2026

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