ork/csv 问题修复 & 功能扩展

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

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

ork/csv

最新稳定版本:2.3.0

Composer 安装命令:

composer require ork/csv

包简介

A library to read and write CSV files.

关键字:

README 文档

README

Ork CSV is a library for reading and writing CSV files.

Latest Version PHP License PHPStan Test Status Code Coverage

Installation

composer require ork/csv

Reader

Ork CSV provides a reader to parse delimited files into arrays. The reader is implemented as an iterator that yields the contents of one CSV line per iteration. If the file has a header line with column names, each yielded array will be associative, keyed by the names in the header. If the file does not have a header line with columns names, each yielded array will be indexed.

For example, a file with a header line:

ID,Name,Size
1,foo,large
2,bar,small
$csv = new \Ork\Csv\Reader('/path/to/file.csv');
foreach ($csv as $row) {
    print_r($row);
}
Array
(
    [ID] => 1
    [Name] => foo
    [Size] => large
)
Array
(
    [ID] => 2
    [Name] => bar
    [Size] => small
)

A file without a header line:

1,foo,large
2,bar,small
$csv = new \Ork\Csv\Reader(file: '/path/to/file.csv', hasHeader: false);
foreach ($csv as $row) {
    print_r($row);
}
Array
(
    [0] => 1
    [1] => foo
    [2] => large
)
Array
(
    [0] => 2
    [1] => bar
    [2] => small
)

Writer

Ork CSV provides a writer that will track columns and automatically generate an appropriate header line.

$csv = new \Ork\Csv\Writer('/path/to/file.csv');
$csv->write([
    'Id' => 1,
    'Name' => 'foo',
    'Size' => 'large',
]);
$csv->write([
    'Id' => 2,
    'Name' => 'bar',
    'Size' => 'small',
]);
Id,Name,Size
1,foo,large
2,bar,small

See the docs directory for full details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-27