protected function process()
    {
        $sourceFp = $this->getSourceFp();
        $destinationFp = $this->getDestinationFp();
        $index = $this->getIndex();
        
        // Extract duplicates in a separate file.
        $duplicateCount = 0;
        foreach ($index as $identifier => $positions) {
            if (count($positions) > 1) {
                // We have a duplicate.
                foreach ($positions as $pos) {
                    rewind($sourceFp);
                    fseek($sourceFp, $pos);
                    $sourceData = fgetcsv($sourceFp);
                    fputcsv($destinationFp, $sourceData);
                    $duplicateCount++;
                }
            }
        }
        
        return new Report(
            Report::TYPE_INFO,
            "${duplicateCount} duplicate records extracted in file '" . realpath($this->getDestination()) . "'."
        );
    }
protected function process()
    {
        $sourceFp = $this->getSourceFp();
        $destinationFp = $this->getDestinationFp();
        $index = $this->getIndex();
        
        // Extract duplicates in a separate file.
        $duplicateCount = 0;
        foreach ($index as $identifier => $positions) {
            if (count($positions) > 1) {
                // We have a duplicate.
                foreach ($positions as $pos) {
                    rewind($sourceFp);
                    fseek($sourceFp, $pos);
                    $sourceData = fgetcsv($sourceFp);
                    fputcsv($destinationFp, $sourceData);
                    $duplicateCount++;
                }
            }
        }
        
        return new Report(
            Report::TYPE_INFO,
            "${duplicateCount} duplicate records extracted in file '" . realpath($this->getDestination()) . "'."
        );
    }
protected function process ( ) { $ sourceFp = $ this -> getSourceFp ( ) ; $ destinationFp = $ this -> getDestinationFp ( ) ; $ index = $ this -> getIndex ( ) ; // Extract duplicates in a separate file. $ duplicateCount = 0 ; foreach ( $ index as $ identifier => $ positions ) { if ( count ( $ positions ) > 1 ) { // We have a duplicate. foreach ( $ positions as $ pos ) { rewind ( $ sourceFp ) ; fseek ( $ sourceFp , $ pos ) ; $ sourceData = fgetcsv ( $ sourceFp ) ; fputcsv ( $ destinationFp , $ sourceData ) ; $ duplicateCount ++ ; } } } return new Report ( Report :: TYPE_INFO , "${duplicateCount} duplicate records extracted in file '" . realpath ( $ this -> getDestination ( ) ) . "'." ) ; }
Duplicate extraction logic.

Extract duplicate rows from the source CSV file to the
destination CSV file.

@see \oat\tao\scripts\tools\AbstractIndexedCsv
Duplicate extraction logic .