修改前:
col1,col2,col3,col4
text1,text2,text3,text4
text5,text6,text7,text8
text9,text10,text11,text12
修改后:
col1,col2,col3,col4
text1,text2,append\text3,text4
text5,text6,append\text7,text8
text9,text10,append\text11,text12
Import-Csv "C:\Users\814072\Desktop\a.csv" | foreach-object {
$_.col3 = ‘append\‘ +$_.col3
$_ #一直不明白这行啥意思,其实看看下面的代码就清楚了,上面那行仅仅将新的col3的值存储在了内存中
} | Export-Csv "C:\Users\814072\Desktop\a2.csv"
Import-Csv -Path "C:\Users\814072\Desktop\a.csv" | foreach {
$_
}
输出:
col1 col2 col3 col4
---- ---- ---- ----
text1 text2 text3 text4
text5 text6 text7 text8
text9 text10 text11 text12
Import-Csv -Path "C:\Users\814072\Desktop\a.csv" | foreach {
$_.col3 = "append\" + $_.col3
}
输出:
无