A simple PHP library to parse and generate CSV files.
gautier.deruette e300b9b1d8 Coquille sur le setter setEnclosure 1 year ago
src/Deblan/Csv Coquille sur le setter setEnclosure 1 year ago
tests Legend attribute 2 years ago
.gitignore composer 3 years ago
LICENSE Init commit 3 years ago
README.md composer 3 years ago
composer.json composer 2 years ago
phpunit.xml test 3 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();