ziyodulloxon/simple-csv 问题修复 & 功能扩展

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

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

ziyodulloxon/simple-csv

Composer 安装命令:

composer require ziyodulloxon/simple-csv

包简介

Simple CSV reader/writer

README 文档

README

Basic Usage

img.png

$reader = new \Ziyodulloxon\SimpleCsv\Reader("./path/to/file.csv");

$rows = $reader->read();

foreach ($rows as $row) {
    var_dump($row);
}

Output:

[
    0 => 111,
    1 => "+79991234567",
    2 => "John Smith",
],
[
    0 => 112,
    1 => "+79881234568",
    2 => "Jane Doe",
],
[
    0 => 49329,
    1 => "+79771234569",
    2 => "Walter White",
]

Using associateWithHeaders() to Use Headers as Keys

$reader = new \Ziyodulloxon\SimpleCsv\Reader("./path/to/file.csv");

$rows = $reader->associateWithHeaders()->read();

foreach ($rows as $row) {
    var_dump($row);
}

Output:

[
    "id_client" => 111,
    "phone" => "+79991234567",
    "name" => "John Smith",
],
[
    "id_client" => 112,
    "phone" => "+79881234568",
    "name" => "Jane Doe",
],
[
    "id_client" => 49329,
    "phone" => "+79771234569",
    "name" => "Walter White",
]

Using batchRead() for Large Files

$reader = new \Ziyodulloxon\SimpleCsv\Reader("./path/to/file.csv");

//$iterable is an instance of \Generator
$iterable = $reader->associateWithHeaders()->batchRead(1);

foreach ($iterable as $item) {
    var_dump($item);
}

Output:

Same as above, but with lower memory usage.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

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