shuchkin/simplecsv

Parse and retrieve data from CSV files. Export data to CSV.

1.0.1 2023-11-14 17:43 UTC

This package is auto-updated.

Last update: 2024-04-14 18:45:30 UTC


README

68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73687563686b696e2f73696d706c65637376 68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73687563686b696e2f73696d706c65637376 68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f73687563686b696e2f73696d706c65637376 68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f73687563686b696e2f73696d706c65637376 68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f73687563686b696e2f73696d706c65637376 68747470733a2f2f696d672e736869656c64732e696f2f6f70656e636f6c6c6563746976652f616c6c2f73696d706c65786c7378 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617472656f6e2d5f2d5f

Parse and retrieve data from CSV files. Save array to CSV file. See XLSX reader here, XLS reader here,

Sergey Shuchkin sergey.shuchkin@gmail.com 2015-2023

Basic Usage

if ( $csv = Shuchkin\SimpleCSV::parse('book.csv') ) {
	print_r( $csv->rows() );
}
Array
(
    [0] => Array
        (
            [0] => ISBN
            [1] => title
            [2] => author
            [3] => publisher
            [4] => ctry
        )

    [1] => Array
        (
            [0] => 618260307
            [1] => The Hobbit
            [2] => J. R. R. Tolkien
            [3] => Houghton Mifflin
            [4] => USA
        )

)

Installation

The recommended way to install this library is through Composer. New to Composer?

This will install the latest supported version:

$ composer require shuchkin/simplecsv

or download class here

Debug

ini_set('error_reporting', E_ALL );
ini_set('display_errors', 1 );

$csv = Shuchkin\SimpleCSV::import('books.csv');
print_r( $csv->rows() );

Export

$items = [
	['ISBN', 'title', 'author'],
	['618260307','The Hobbit','J. R. R. Tolkien']
];
$csv = Shuchkin\SimpleCSV::export( $items );
echo '<pre>' . $csv . '</pre>';
/*
ISBN,title,author
618260307,The Hobbit,J. R. R. Tolkien
*/

History

1.0 (2023-08-27)

  • used namespace now: Shuchkin\SimpleCSV
  • fixed delimiter detection

0.2 (2023-07-27)

  • fix 8x deprication Passing null to parametr
  • added static methods SimpleCSV::parse, SimpleCSV::parseFile, SimpleCSV::parseData

0.1.1 (2021-04-28) fix 7.4 deprication error
0.1 (2018-12-20) GitHub realese, composer