alexbrandes / simplecsv
Simple and flexible library for reading and manipulating CSV files in PHP.
dev-master / 0.0.1.x-dev
2014-07-09 04:57 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2025-05-06 05:25:35 UTC
README
SimpleCsv is a simple and flexible library for reading and manipulating CSV files.
Usage
Read CSV from File
$csv = \Reader::create_from_file('./dat.csv');
Read CSV from String
$str = 'header 1, header 2 data 1, data 2'; $csv = \Reader::create_from_string($str);
CSV to Array
// associative array using first line as headers $csv = \Reader::create_from_file('./dat.csv') ->to_assoc(); // indexed array w/ no headers $csv = \Reader::create_from_file('./dat.csv') ->to_array();
Detect Delimiter
// automatically detect and set the file delimiter type $csv = \Reader::create_from_file('./dat.csv') ->detect_delimiter(array('|', '%', '$')) ->to_assoc();
Installation
Install the SimpleCsv
package with Composer.
{ "require": { "AlexBrandes/SimpleCsv": "*" } }
Read more about Composer
System Requirements
PHP >= 5.3.0
TODO
- Write to Csv
- Tests
Credits
- Written and maintained by Alex Brandes