baolq2020 / rdcsv
从 csv 文件读取数据
dev-master
2020-03-13 03:58 UTC
This package is auto-updated.
Last update: 2024-09-13 14:21:38 UTC
README
设置
composer require baolq2020/rdcsv:dev-master
示例
我们有两种方式使用这个库
#您可以使用函数将 csv 转换为数组。
完整选项
$Iacsv = Iacsv::start('path file') ->setRowStart(2) // This is option( Default 0 ) ->setIsUTF8(true) // This is option( Will be auto detect if you don't set ) ->setDelimiter(';') // This is option( Will be auto detect if you don't set ) ->all();
快速方式(自动检测,性能较慢)
$Iacsv = Iacsv::start('path file')->all();
#您可以通过循环 csv 文件并获取单行内容来提高性能
$Iacsv = new Iacsv($pathFile); $Iacsv->setRowStart(11); // This is option( Default 0 ) $Iacsv->setIsUTF8(true); // This is option( Will be auto detect if you don't set ) $Iacsv->setDelimiter(';'); // This is option( Will be auto detect if you don't set ) $Iacsv->openSingleRow(); while ($Iacsv->checkIsNotEof()) { $singleRow = $Iacsv->getSingleRow(); // You can get your single row data here. print_r($singleRow); }