2017 © Pedro Peláez
 

library csv-parser

CSV Parser Library for PHP

image

hikarine3/csv-parser

CSV Parser Library for PHP

  • Saturday, May 19, 2018
  • by hikarine3
  • Repository
  • 1 Watchers
  • 1 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 11 % Grown

The README.md

What is this

Simple CSV parser for PHP. Return characters will be converted into, (*1)

<br />

How to install it

composer require hikarine3/csv-parser;

at the directory where composer.json exists, (*2)

Example: First line will be used as key

Let's consider csv file whose column name is id and name, (*3)

$file = "input.csv";
$delimiter = ",";
$parser = new CsvParser();
$datas = $parser->parse({"delimiter" => $delimiter, file" => $file});
foreach ($datas as $data) {
    if(isset($data['id']) && isset($data['name']) ) {
/* ... */
    }
}

Default deliiter is ',', (*4)

Example of using this library for Laravel's seeder

<?php

use Illuminate\Database\Seeder;
use Hikarine3\CsvParser;
use Carbon\Carbon;

class CountrySeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        ini_set('memory_limit','1024M');
        $file = __DIR__ .'/data/locations/countries.tsv';
        $parser = new CsvParser();
        $datas = $parser->parse(['delimiter' => "\t", 'file' => $file]);

        foreach ($datas as $data) {
            if(isset($data['id']) && isset($data['name']) ) {
                DB::table('countries')->insert([
                    'id' => $data['id'],
                    'name' => $data['name'],
                    'created_at' => Carbon::now(),
                    'updated_at' => Carbon::now()
                ]);
            }
        }
    }
}

License / ライセンス / 执照

MIT, (*5)

Author / 作者

Name / 名前 / 全名

Hajime Kurita, (*6)

Twitter

  • EN: https://twitter.com/hajimekurita
  • JP: https://twitter.com/hikarine3

Blog

  • EN: https://en.sakuhindb.com/pe/Administrator/
  • JP: https://sakuhindb.com/pj/6_B4C9CDFDBFCDA4B5A4F3/

Technical web services / 提供してる技術関連Webサービス / 技术网络服务

VPS & Infra comparison / VPS比較 / VPS比较

  • EN: https://vpsranking.com/en/
  • CN: https://vpsranking.com/zh/
  • JP: https://vpshikaku.com/

Programming Language Comparison / プログラミング言語比較 / 编程语言比较

  • EN: https://programminglang.com/en/
  • CN: https://programminglang.com/zh/
  • JP: https://programminglang.com/ja/

OSS

  • Docker: https://hub.docker.com/u/1stclass/
  • Github: https://github.com/hikarine3
  • NPM: https://www.npmjs.com/~hikarine3
  • Perl: http://search.cpan.org/~hikarine/
  • PHP: https://packagist.org/packages/hikarine3/
  • Python: https://pypi.org/user/hikarine3/

The Versions

19/05 2018

dev-master

9999999-dev https://github.com/hikarine3/CsvParser

CSV Parser Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Hajime Kurita

csv parser tsv

19/05 2018

v0.1.9

0.1.9.0 https://github.com/hikarine3/CsvParser

CSV Parser Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Hajime Kurita

csv parser tsv

19/05 2018

v0.1.8

0.1.8.0 https://github.com/hikarine3/CsvParser

CSV Parser Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Hajime Kurita

csv parser tsv

15/05 2018

v0.1.7

0.1.7.0 https://github.com/hikarine3/CsvParser

CSV Parser Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Hajime Kurita

csv parser tsv

30/04 2018

v0.1.6

0.1.6.0 https://github.com/hikarine3/CsvParser

CSV Parser Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Hajime Kurita

csv parser tsv

29/04 2018

v0.1.5

0.1.5.0 https://github.com/hikarine3/CsvParser

CSV Parser Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Hajime Kurita

csv parser tsv

29/04 2018

v0.1.4

0.1.4.0 https://github.com/hikarine3/CsvParser

CSV Parser Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Hajime Kurita

csv parser tsv

29/04 2018

v0.1.3

0.1.3.0 https://github.com/hikarine3/CsvParser

CSV Parser Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Hajime Kurita

csv parser tsv

29/04 2018

v0.1.2

0.1.2.0 https://github.com/hikarine3/CsvParser

CSV Parser Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Hajime Kurita

csv parser tsv

29/04 2018

v0.1.1

0.1.1.0 https://github.com/hikarine3/CsvParser

CSV Parser Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Hajime Kurita

csv parser tsv

29/04 2018

0.1

0.1.0.0 https://github.com/hikarine3/CsvParser

CSV Parser Library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Hajime Kurita

csv parser tsv