Skip to content

Simple PHP class providing a clean, readable and extensible interface for processing CSV files

License

Notifications You must be signed in to change notification settings

ogrrd/csv-iterator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 

Repository files navigation

csv-iterator

CSV Reader to array/object iterator with low memory usage and ease of use. Mostly useful for importing large CSV files from external APIs.

Installation

Add this to your composer.json:

{
    "require": {
        "ogrrd/csv-iterator": "dev-master"
    }
}

Or just type: composer require ogrrd/csv-iterator

Usage

Reading data out of a CSV file:

use ogrrd\CsvIterator\CsvIterator;

$pathToFile = '/path/to/file.csv';
$delimiter = ','; // optional
$rows = new CsvIterator($pathToFile, $delimiter);
$rows->useFirstRowAsHeader();
foreach ($rows as $row) {
    // print_r($row);
}

Features

  • Set array of values to be used as keys for the rows (must cover all columns)
  • Use the values from the first row as the keys for the remaining rows

Todo

  • Unit tests

License

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

About

Simple PHP class providing a clean, readable and extensible interface for processing CSV files

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%