tranquilo / parsecsv
一个简单的CSV解析器,返回一个多维数组。该类非常易于安装和使用,兼容PSR。
1.0.0
2018-04-29 14:55 UTC
Requires (Dev)
- phpunit/phpunit: 5.3.3
This package is not auto-updated.
Last update: 2024-09-29 05:48:29 UTC
README
##Parse-csv
Tranquilo Parse-csv 是一个小巧的PHP应用程序库。该库允许您传递一个CSV文件,进行一些验证以确保您的数据以数组的形式返回。
安装
您可以使用Composer安装此库
$ composer require tranquilo/parsecsv This project requires PHP 5.5 and has no dependencies. The code is intended to comply with [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/), and [PSR-4](http://www.php-fig.org/psr/psr-4/). If you find any issues related to standards compliance, please send a pull request!
示例
一些示例。
<?php require __DIR__ . '/vendor/autoload.php'; use Tranquilo\ParseCsv; ///use Tranquilo\Exceptions\CsvException; try{ // filepath, delimiter : optional $csv = new ParseCsv(__DIR__ . '/test.csv', ","); // optional convert the encoding $csv->convertEncoding('UTF-8'); // // starts from 5 $withOffset = $csv->getWithOffset(5); // gets all rows $allRowsCsv = $csv->get(5); // gets 10 rows starting from 5 $withLimitAndOffset = $csv->get(5, 2); print_r($allRowsCsv); unset($csv); }catch(CsvException $e){ echo $e->getMessage(); }catch(Exception $e){ echo $e->getMessage(); }