Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active April 3, 2016 03:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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