【发布时间】:2016-11-23 14:14:55
【问题描述】:
当A列的值(即DevID)等于B列的值(即ProdID)时,需要删除CSV文件的整行
我的代码:
$MergedFile= Import-Csv "C:\Users\d-mansings\Desktop\Mergedata.csv"
$MergeTable=@{}
foreach($line in $MergedFile){
if(Compare-Object $line.DevID $line.ProdID){
echo "Not Matched, Keep the file as it"}
else{ echo "Row need to be deleted"}
}
我需要一个可以删除整行的命令来代替 Row need to be deleted。
以下是我的CSV 文件:
"DevID","ProdID","cfname"
"-----","-----","------"
"10201","10202","Risk ID"
"10202","20202","Issue ID"
"10203","20203","Dependency ID"
"10204","20204","Server ID"
"10205","20205","Parent Application ID"
"10206","20206","Application Service ID"
"10207","20207","Application Supportability"
"10208","20208","Application Compatibility"
"10300","20300","Application Status"
"10301","20302","Contact ID Type 2"
"10302","20302","Contact ID Type 3"
"10303","20303","Contact ID Type 4"
"10304","10304","Business Service Manager"
"10308","20308","Server Location Name:"
【问题讨论】:
标签: csv powershell export-to-csv delete-row