Skip to content

Instantly share code, notes, and snippets.

@kurozumi

kurozumi/Reader.php

Last active Apr 3, 2016
Embed
What would you like to do?
【PHP】League\Csvを拡張してCSVファイルの任意のカラムの重複したデータを削除する方法
<?php
namespace Acme\Csv;
class Reader extends \League\Csv\Reader
{
/**
* @param int $offsetIndex
* @return Generator
*/
public function fetchDeduplicate($offsetIndex=0)
{
$iterator = $this->getQueryIterator();
foreach ($iterator as $row) {
yield $row[$offsetIndex] => implode(",", $row);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment