digitaldream/data-converter 问题修复 & 功能扩展

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

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

digitaldream/data-converter

最新稳定版本:1.3.0

Composer 安装命令:

composer require digitaldream/data-converter

包简介

In web application we need to convert data from one type to another. For example, array to excel file or excel file to array.

README 文档

README

something in web application we need to convert data from excel file to array, array to excel file and more. ##How to install

  "require-dev": {
     "digitaldream/data-converter": "1.0.*"
}

##Features

  1. Excel to Array and associative array (if first row marked as heading)
  2. Excel to json(json to excel)
  3. Excel to text(text to excel)
  4. Filter data while import from excel,json,txt,csv
  5. And from one format you can exchange other easily

##Uses

Example 01

$fileManager = new \DataConverter\FileExcel();

A lot of other configuration like you can define from which row you like to read and how many row it will be read. Also you can append data to file.

  $config = [
    'file_path' => 'C:\Users\Tuhin\Downloads\apiv1567623ccbcfc1_570a009e10650.xlsx',    
    'first_row_as_headline' => true,    
  ];

  $data = $fileManager->config($config)->read()->getData();   
  //$data = $fileManager->config($config)->read()->toJson();  
  //$data = $fileManager->config($config)->read()->toText();  
  //$data = $fileManager->config($config)->read()->toAssoc(); 
  print_r($data);  
  ?>

Example 02

//Here it will process the file based on file mimetype. 

$fileFullPath='test.txt';

  $fileManager = \DataConverter\FileManager::initByFileType($fileFullPath);

if ($fileManager === FALSE) {
 // exit() File tye does not mathch 
 }
 
 //here we used filter. It will take only these two columns value and other data from the souce will be ignored.
 
 $data = $fileManager->config($config)->read()->makeAssoc()->filter(['column_1','column_2])->getData();

Example 03

 $fileManager = new \DataConverter\FileExcel();
 $configFile = [ 
     'file_path' => $fullPath,// full file path where file will be saved.     
       'data' => $data,//data as associative array.       
       'mode' => 'w+'//only valid if file type is txt       
    ];
  $fileManager = $fileManager->config($configFile)->filter(['column 1','column 2'])->write(true);

More examples is in demo/exmaples.php file

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-27