这是lab8.ps1
一切都运行得很好,.csv用分隔符拆分它,并抓住第一个字段,然后它去了第一个字段并抓住用户的姓氏并放入它到.txt文档中供以后使用。
for ($n = 1; $n -lt 100; $n++) {
$test = (Get-Content "C:\Users\Administrator\Documents\lab8\Lab8_db1.csv")[$n].Split(",")
for ($i = 0; $i -lt 1; $i++) {
(Get-Culture).TextInfo.ToTitleCase($test[$i]) >> "C:\Users\Administrator\Documents\lab8\UsersF.txt"
for ($i = 1; $i -lt 2; $i++) {
(Get-Culture).TextInfo.ToTitleCase($test[$i]) >> "C:\Users\Administrator\Documents\lab8\UsersL.txt"
}
}
}
for ($i = 0; $i -lt 99; $i++) {
$concatFirstWEmail = (Get-Content "C:\Users\Administrator\Documents\lab8\UsersF.txt")[$i]
$emails = "$concatFirstWEmail".ToLower() + "Senecacolleg.biz" >> "C:\Users\Administrator\Documents\lab8\emails.txt"
}
Import-Csv "C:\Users\Administrator\Documents\lab8\UsersF.txt" -Header GivenName -Delimiter "," |
Export-Csv -NoTypeInformation "C:\Users\Administrator\Documents\lab8\usersF.csv"
Import-Csv "C:\Users\Administrator\Documents\lab8\UsersL.txt" -Header SurName -Delimiter "," |
Export-Csv -NoTypeInformation "C:\Users\Administrator\Documents\lab8\usersL.csv"
Import-Csv "C:\Users\Administrator\Documents\lab8\emails.txt" -Header emails -Delimiter "," |
Export-Csv -NoTypeInformation "C:\Users\Administrator\Documents\lab8\emails.csv"
mergelab8.ps1
包含
$CSV1 = Import-Csv -Path "C:\Users\Administrator\Documents\lab8\usersF.csv"
$CSV2 = Import-Csv -Path "C:\Users\Administrator\Documents\lab8\usersL.csv"
$CSV3 = Import-Csv -Path "C:\Users\Administrator\Documents\lab8\emails.csv"
$CSV1.GivenName + $CSV2.SurName + $CSV3.emails >> "$HOME\Documents\lab8\test.csv"
如何将所有这三个文件合并为一个.csv,以便获得此输出?
Ylnum Vybghjv ylnumSenecacolleg.biz Dexcd Mnyuait dexcdSenecacolleg.biz Igbos Nlbihjz igbosSenecacolleg.biz Rzjlr Wddbcjp rzjlrSenecacolleg.biz Jjjwa Qylrkoe jjjwaSenecacolleg.biz