具有执行查找的脚本。如果没有匹配项,如何将其更改为保留原始值。现在它留空了。
$PSDefaultParameterValues['*:Encoding'] = 'utf8'
$f1 = (Import-Csv 'A.txt' -Delimiter 'µ' -Header samname, id)
$f2 = (Import-Csv 'B.txt' -Delimiter 'µ' -Header samname, id)
$f1 | %{
$samname = $_.samname
$m = $f2 | ?{$_.samname -eq $samname}
$_.id = $m.id
}
$f1 | Export-Csv 'C.txt' -NoType
输入:
A.txt
:
T3-F2-P8629-A1033-L999:µDue Date Calculation T3-F2-P8629-A1063-L999:µDue Date Calculation missing missing
B.txt
:
T3-F2-P8629-A1033-L999:µDue Date Calculation T3-F2-P8629-A1063-L999:µMok. termino skaičiavimas T3-F8-P8629-A1033-L999:µLast Modified Date Time T3-F8-P8629-A1063-L999:µLast Modified Date Time
输出(C.txt
):
"T3-F2-P8629-A1033-L999:","Due Date Calculation" "T3-F2-P8629-A1063-L999:","Mok. termino skaičiavimas" "T3-F8-P8629-A1033-L999:", "T3-F8-P8629-A1063-L999:",
预期输出:
"T3-F2-P8629-A1033-L999:","Due Date Calculation" "T3-F2-P8629-A1063-L999:","Mok. termino skaičiavimas" "T3-F8-P8629-A1033-L999:","Last Modified Date Time" "T3-F8-P8629-A1063-L999:","Last Modified Date Time"