lantongxue/csv-reader
Composer 安装命令:
composer require lantongxue/csv-reader
包简介
A high-performance and low-memory CSV reader
README 文档
README
A high-performance and low-memory CSV reader
Usage
install
composer require lantongxue/csv-reader
CSVReader constructor parameters:
CSVReader(string $csvFile, bool $firstRowIsHeader = true, array $getcsvParams = [])
$csvFile Specify CSV file path
$firstRowIsHeader Setting the first row as the header row, default true
$getcsvParams This parameter exists for compatibility with php8, but also improves the flexibility of csv reading, the specific parameter structure is as follows:
[
'separator' => ",",
'enclosure' => "\"",
'escape' => "\\",
];
Refer to the fgetcsv function for the exact meaning.
Reading through an iterator
$csv = 'test.csv'; $reader = new lantongxue\CSVReader($csv); foreach($reader as $row) { // todo }
Chunked read
$csv = 'test.csv'; $reader = new lantongxue\CSVReader($csv); $reader->Chunk(function($rows) { foreach($rows as $row) { // todo } return true; }, 1000);
Other Api
GetHeader() Return header row when the $firstRowIsHeader is true
License
MIT
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-13