lantongxue/csv-reader 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-13