fbk/csvmapper 问题修复 & 功能扩展

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

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

fbk/csvmapper

Composer 安装命令:

composer require fbk/csvmapper

包简介

CSV parser with callbacks on fields

关键字:

README 文档

README

Official repo stats

Build Status Coverage Status Scrutinizer Quality Score

CSVMapper is a PHP library which parses CSV files.

It allows to map the file to an array by defining some file configurations and each (wanted) columns properties.

File Settings

CSVMapper needs to now where the file is located and which is the columns separator.

It il also possible to specify how many columns are expected so that it aborts if the number of columns doesn't match.

    $setting = new SettingManager();
    $config->set_setting('folder','./tests');
    $config->set_setting('filename','myfile.csv');
    $config->set_setting('separator',';');
    $config->set_setting('columns_allowed',3);

Mappings

CSVMapper extracts only the columns which are defined with mappings. With a mapping it is possible to specify the position of the column, which function to apply to the value and how to test the value.

    $mapping = new MappingManager();
    // retrieve column number 1 (counting from 0) and label it as year
    $mapping->set_mapping("year", array('key'=>1,'fn'=>FALSE,'test'=>FALSE));
    // retrieve column number 2 (counting from 0) and label it as temperature, apply to each value the function 'return floatval($input);'
    $mapping->set_mapping("temperature", array('key'=>2, 'fn'=>create_function('$input','return floatval($input);'),'test'=>FALSE));

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-08-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固