ETidalgo
7/24/2018 - 11:22 PM

Find duplicate column values in a CSV file

import-csv group-object

/*
$csvFile = "Duplicate invoice line rows appearing\ReconciliationDetails_20180713_1211.csv"
$columnName = "Delivery No"

$recon = import-csv $csvFile

$recon | group-object -Property $columnName | ? { $_.Count -gt 1 } 
*/

function FindDuplicateColumnValuesInCsv {
  param(
    [string]$CsvFile,
    [string]$ColumnName = "Delivery No")

  $recon = import-csv $csvFile
   
  $recon | group-object -Property $columnName | ? { $_.Count -gt 1 }   
}