承接 iamgold/dataloader-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

iamgold/dataloader-php

最新稳定版本:v1.0.1

Composer 安装命令:

composer require iamgold/dataloader-php

包简介

This library provides a simple and lightweight component to help loading data into csv, tsv or parquet etc....

README 文档

README

This is a lightweight, simple and flexible library for exporting data, and now support csv, tsv, parquet etc....

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Getting Start

Features

  • Support csv
  • Support tsv
  • Support parquet

Requirements

  • PHP 8.0+
  • ext-snappy (optional when using ParquetLoader and Snappy compression method)
  • ext-zip

Install

composer require iamgold/dataloader-php

Usage

// prepare column definitions
$defs = [
    ['id', 'int', 0], // name, type, defaultValue
    ['name', 'string', '-'],
    ['gender', 'string', '-'],
    ['email', 'email', '-'],
    ['join_date', 'dateTime', '-']
];

// prepare columns for each definitions and mapping related type calss.
$columns = [];
foreach($defs as $def) {
    list($name, $type, $defaultValue) = $def;
    $typeClass = match ($type) {
        'int' => new Integer,
        'string' => new Strings,
        'dateTime' => new DateTime,
        'email' => new Email,
        default => null,
    };

    if ($typeClass === null)
        die("The type($type) doest't support");

    // create column by name and type
    $columns[] = new Column($name, $typeClass);
}

// prepare data
$data = [
    [1, 'Eric', 'male', 'eric@abc.com', date('Y-m-d')],
    [2, 'Peter', 'male', 'peter@abc.com', date('Y-m-d')],
    [3, 'Marry', 'female', 'marry@abc.com', date('Y-m-d')],
    [5, 'Jenny', 'female', 'jenny@abc.com', date('Y-m-d')],
    [100, 'Mandy', 'f', 'mandy@abc.com', date('Y-m-d')],
];

// create a file manager for storing file
$fileManager = new FileManager(__DIR__, 'csv', '20221113_');

// create loader for collecting data and parsing into columns
$loader = new CsvLoader($columns, ',', true);
$loader->setFileManager($fileManager);

// push data
foreach($data as $r) {
    $loader->push($r, false);
}

// load by file manager
$result = $loader->load();

Documents

comming soon...

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2022-11-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固