当前脚本:
$csv = Import-Csv .\test1.csv -Delimiter ';'
$ref = @($csv.Column1)
foreach ($row in $csv) {
foreach ($col in 'Column2', 'Column3', 'Column4') {
if ($ref -contains $row.$col) { $row.$col = '' }
}
}
$csv | Select-Object Column1,Column2,Column3,Column4
目前的结果:
Column1 Column2 Column3 Column4 ------- ------- ------- ------- infra-1 infra-852 infra-99 infra-98 infra-85 infra-44 infra-23 infra-5 infra-8 infra-10 infra-2 infra-55 infra-8 infra-70 infra-62 infra-852
CSV文件:
Column1 Column2 Column3 Column4 infra-1 infra-852 infra-2 infra-99 infra-98 infra-85 infra-44 infra-23 infra-5 infra-8 infra-1 infra-10 infra-2 infra-55 infra-8 infra-70 infra-62 infra-5 infra-852 infra-5
Column1 Column2 Column3 Column4 ------- ------- ------- ------- infra-98 infra-852 infra-44 infra-99 infra-62 infra-85 infra-8 infra-23 infra-8 infra-852 infra-10 infra-55 infra-70 Column1 Column2 Column3 Column4 ------- ------- ------- ------- infra-1 infra-85 infra-2 infra-99 infra-98 infra-55 infra-44 infra-23 infra-2 infra-1 infra-10 infra-62 infra-70
要简短,我希望有四列只有与参考列不匹配的单元格。列引用的值必须与其匹配的值不连贯。这个问题是关于制作许多数组,另一个问题是关于排除空单元格。