PHPackages                             cfv1000/csv-reader - 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. cfv1000/csv-reader

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

cfv1000/csv-reader
==================

Another PHP csv reader

2.0.4(8mo ago)0543[1 PRs](https://github.com/flaviu-chelaru/csv-reader/pulls)MITPHPPHP ~7.1 || ~8.0CI passing

Since Jul 21Pushed 5d agoCompare

[ Source](https://github.com/flaviu-chelaru/csv-reader)[ Packagist](https://packagist.org/packages/cfv1000/csv-reader)[ RSS](/packages/cfv1000-csv-reader/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (3)Versions (14)Used By (0)

[![Tests](https://github.com/flaviu-chelaru/csv-reader/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/flaviu-chelaru/csv-reader/actions/workflows/tests.yml)[![Latest Stable Version](https://camo.githubusercontent.com/da97d0697b5a9be337cc0a06eebaf91b2ed60ef6cf9c0f5cacea78fa89f757ad/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636676313030302f6373762d7265616465722e7376673f7374796c653d666c61742d737175617265266c6162656c3d737461626c65)](https://packagist.org/packages/cfv1000/csv-reader)[![PHP Version Require](https://camo.githubusercontent.com/3e6e3ce07c62d6f89ac1a76fefed0866aeb1eac938017b6ffcb7eccabc65b300/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f636676313030302f6373762d7265616465722f7068703f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cfv1000/csv-reader)[![Total Downloads](https://camo.githubusercontent.com/0115f31945395bc1e7210550f8fa9beab4cd7c3b767688fd7960625c4fcece92/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636676313030302f6373762d7265616465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cfv1000/csv-reader)[![Monthly Downloads](https://camo.githubusercontent.com/25f7a608d986055c7a176b028d6b4744735b1bce5f9b25fc0d516c566a3d1fb4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f636676313030302f6373762d7265616465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cfv1000/csv-reader)[![License](https://camo.githubusercontent.com/30737adf70a93dcf19979e368d62d8b327fea226a009e4159f85d582804a846a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636676313030302f6373762d7265616465722e7376673f7374796c653d666c61742d737175617265)](https://github.com/flaviu-chelaru/csv-reader/blob/master/LICENSE)[![PHPUnit](https://camo.githubusercontent.com/32ea3123978ccf373844f42474eb9d6e6111bca1beca5389a1150f7576abcb66/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850556e69742d392e352d626c75652e7376673f7374796c653d666c61742d737175617265266c6f676f3d706870)](https://phpunit.de/)[![Rector](https://camo.githubusercontent.com/f088cceb3d72a98bf763bf3327365081d90d9418c6b023dd717467dddec3ae0f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f526563746f722d312e322d626c756576696f6c65742e7376673f7374796c653d666c61742d737175617265)](https://getrector.com/)[![PSR-4](https://camo.githubusercontent.com/aad34d4fcd3556ece898aad61337f2087b23aa1c4d3d7b92373adfe777c3d9cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d2d342d6175746f6c6f61642d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://www.php-fig.org/psr/psr-4/)

🚀 Why Use This Class?
=====================

[](#-why-use-this-class)

This class is a solid choice for several reasons:

**Memory Efficiency:** Unlike methods that read the entire file into an array, this class implements the Iterator interface. This means it reads the file line by line, which is crucial for processing large datasets without exhausting your server's memory. This is particularly useful in environments with limited RAM or when dealing with multi-gigabyte files.

**Flexibility:** It allows you to customize the core parameters of your CSV file. You can specify different column, line, and enclosure characters in the constructor. This adaptability makes it suitable for reading CSV files from various sources that may use different delimiters.

**Countable and Iterator Interfaces:** By implementing the Countable interface, you can easily get the total number of lines in the file using the count() method. The Iterator interface implementation means you can use the class directly in foreach loops, providing a clean and familiar way to process each line of the CSV.

**Low-Level Control:** The class gives you fine-grained control over the file pointer with methods like seek() and tell(), which can be useful for advanced operations like resuming a process or navigating to a specific part of the file.

**SplFileObject Utilization:** The class leverages PHP's built-in SplFileObject which is part of the Standard PHP Library (SPL). SplFileObject is an object-oriented interface for file handling, offering a more robust and feature-rich way to interact with files than traditional functions like fopen() and fgetcsv(). This ensures stable and reliable file operations.

✍️ Usage Examples
=================

[](#️-usage-examples)

**Basic Usage**To read a basic comma-separated file, just provide the file path:

```
use cfv1000\CsvReader\Reader;

$csv = new Reader('path/to/your/file.csv');

foreach ($csv as $line) {
    print_r($line);
}
```

Customizing Delimiters
----------------------

[](#customizing-delimiters)

If your file uses a different delimiter, like a semicolon, you can specify it:

```
use cfv1000\CsvReader\Reader;

// Semicolon-separated file
$csv = new Reader('path/to/your/semicolon_file.csv', ';');

foreach ($csv as $line) {
    print_r($line);
}
```

Counting Lines
--------------

[](#counting-lines)

You can easily get the total line count using the count() method.

```
use cfv1000\CsvReader\Reader;

$csv = new Reader('path/to/your/file.csv');

$lineCount = count($csv); // This will return the total number of lines
echo "Total lines: " . $lineCount;
```

Note: Calling count() will move the file pointer to the end of the file. If you need to loop through the file again after counting, you must call the rewind() method first.

```
use cfv1000\CsvReader\Reader;

$csv = new Reader('path/to/your/file.csv');

$lineCount = count($csv);
echo "Total lines: " . $lineCount . PHP_EOL;
// Rewind the file pointer to the beginning to start reading
$csv->rewind();

foreach ($csv as $line) {
    print_r($line);
}
```

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance82

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity75

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

Recently: every ~284 days

Total

11

Last Release

265d ago

Major Versions

1.1.1 → 2.0.02022-07-12

PHP version history (2 changes)1.0.0PHP ~7.0

2.0.0PHP ~7.1 || ~8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/13b6b73a69c16b06d2fc6296529526423796dc1098acc0155edd54f17a54e909?d=identicon)[cfv1000](/maintainers/cfv1000)

---

Top Contributors

[![flaviu-chelaru](https://avatars.githubusercontent.com/u/3073353?v=4)](https://github.com/flaviu-chelaru "flaviu-chelaru (4 commits)")

---

Tags

csvenditeratorline-endingmemoryreadercsvcustom line endingsiterator csvpause or resume via tell and seek

###  Code Quality

TestsPHPUnit

Static AnalysisRector

### Embed Badge

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

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

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[league/csv

CSV data manipulation made easy in PHP

3.5k166.1M646](/packages/league-csv)[rap2hpoutre/fast-excel

Fast Excel import/export for Laravel

2.3k24.9M47](/packages/rap2hpoutre-fast-excel)[openspout/openspout

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

1.1k57.6M131](/packages/openspout-openspout)[goodby/csv

CSV import/export library

9555.6M23](/packages/goodby-csv)[sonata-project/exporter

Lightweight Exporter library

44920.9M35](/packages/sonata-project-exporter)

PHPackages © 2026

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