开发者

merge two .csv files into one file

开发者 https://www.devze.com 2023-04-01 08:34 出处:网络
I have two .csv files that I want to combine into one. FileA has headers of DisplayName and Email FileB has header of Owners. I have not been able to merge the two as one. Any help is appreciated.

I have two .csv files that I want to combine into one.

FileA has headers of DisplayName and Email

FileB has header of Owners. I have not been able to merge the two as one. Any help is appreciated.

The new file needs to have the headers as:

DisplayName      Email                                          开发者_开发技巧 Owners

AccountA           AccountA@company.com           John.doe@company.com


This is one way of doing it:

$filea = import-csv filea.csv
$fileb = import-csv fileb.csv

for($i=0;$i -lt $filea.count;$i++){
    $filea[$i] | Add-Member -MemberType NoteProperty -Name Owners -Value $fileb[$i].Owners
}

$filea | export-csv combined.csv -notype
0

精彩评论

暂无评论...
验证码 换一张
取 消