PHP Classes

How to Implement PHP CSV Parsing to Extract Rows of Data From CSV Files Using the Package CSV Reader Class: Read data from CSV files using generators

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-06-21 (13 days ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
csv-reader-class 1.0.0MIT/X Consortium ...5.5PHP 5, Files and Folders, Language, P...
Description 

Author

This package can read data from CSV files using generators.

It provides a class that can open a given CSV file and parse the data rows.

The class provides a generator function to return one row of data at a time.

Innovation Award
PHP Programming Innovation award nominee
June 2025
Nominee
Vote
CSV files are used by many applications to store information that may appear in the form of tables for the users to see. PHP provides a way to read CSV files.

This package takes advantage of PHP generators to provide a modern way to read the data from the rows of a CVS file.

Manuel Lemos
Picture of Omar Andrés Barbosa Ortiz
  Performance   Level  
Name: Omar Andrés Barbosa ... is available for providing paid consulting. Contact Omar Andrés Barbosa ... .
Classes: 5 packages by
Country: Colombia Colombia
Age: ???
All time rank: 381622 in Colombia Colombia
Week rank: 195 Up2 in Colombia Colombia Up
Innovation award
Innovation award
Nominee: 4x

Instructions

Please read this document to learn how to read CSV files using a PHP generator function.

Documentation

CSV reader

Latest Version on Packagist Tests Total Downloads

This is where your description should go. Try and limit it to a paragraph or two. Consider adding a small example.

Support us

<img src="https://github-ads.s3.eu-central-1.amazonaws.com/csv.jpg?t=1" width="419px" />

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require barbosa89/csv

Usage

use Barbosa\Csv\Reader;

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

foreach($reader->read() => $row) {
    // code
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


  Files folder image Files (19)  
File Role Description
Files folder image.github (2 files, 2 directories)
Files folder imagesrc (1 file, 1 directory)
Files folder imagetests (1 file, 1 directory)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file .php-cs-fixer.dist.php Example Example script
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (19)  /  .github  
File Role Description
Files folder imageISSUE_TEMPLATE (2 files)
Files folder imageworkflows (4 files)
  Accessible without login Plain text file dependabot.yml Data Auxiliary data
  Accessible without login Plain text file FUNDING.yml Data Auxiliary data

  Files folder image Files (19)  /  .github  /  ISSUE_TEMPLATE  
File Role Description
  Accessible without login Plain text file bug.yml Data Auxiliary data
  Accessible without login Plain text file config.yml Data Auxiliary data

  Files folder image Files (19)  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file dependabot-auto-merge.yml Data Auxiliary data
  Accessible without login Plain text file fix-php-code-style-issues.yml Data Auxiliary data
  Accessible without login Plain text file run-tests.yml Data Auxiliary data
  Accessible without login Plain text file update-changelog.yml Data Auxiliary data

  Files folder image Files (19)  /  src  
File Role Description
Files folder imageConstants (1 file)
  Plain text file Reader.php Class Class source

  Files folder image Files (19)  /  src  /  Constants  
File Role Description
  Accessible without login Plain text file Delimiter.php Aux. Configuration script

  Files folder image Files (19)  /  tests  
File Role Description
Files folder imagefixtures (1 file)
  Plain text file CsvReaderTest.php Class Class source

  Files folder image Files (19)  /  tests  /  fixtures  
File Role Description
  Accessible without login Plain text file sample.csv Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads  
 100%
Total:0
This week:0