A simple PHP library to parse and generate CSV files.

gautier.deruette e300b9b1d8 Coquille sur le setter setEnclosure 8 months ago
src e300b9b1d8 Coquille sur le setter setEnclosure 8 months ago
tests d4fa62cea9 Legend attribute 1 year ago
.gitignore 8b3f576665 composer 2 years ago
LICENSE 98d6b8673e Init commit 2 years ago
README.md 155d08cc55 composer 2 years ago
composer.json b806c85932 composer 1 year ago
phpunit.xml 96c829967f test 2 years ago

README.md

CSV parser/generator

A simple PHP library to parse and generate CSV files.

Composer installation

$ composer require deblan/csv

Or in your composer.json:

{
    "require": {
        [...]
        "deblan/csv": "dev-master"
    }
}

Usages

Generator

use Deblan\Csv\Csv;

$csv = new Csv();

$csv->addLine(array('Foo', '$1000'));
$csv->addLine(array('Bar', '$600'));

$result = $csv->compile();
use Deblan\Csv\Csv;

$csv = new Csv();

$csv->setLegend(array('product name', 'price'));
$csv->addLine(array('Foo', '$1000'));
$csv->addLine(array('Bar', '$600'));

$csv->compileToFile('products.csv');

Parser

use Deblan\Csv\CsvParser;

$csv = new CsvParser('products.csv');
$csv->setHasLegend(true);
$csv->parse();

$legend = $csv->getLegend();
$products = $csv->getDatas();