Last active
April 3, 2016 03:05
-
-
Save kurozumi/972138caaf302638b10986f4c3bc8adf to your computer and use it in GitHub Desktop.
【PHP】League\Csvを拡張してCSVファイルの任意のカラムの重複したデータを削除する方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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