【发布时间】:2018-08-13 01:07:23
【问题描述】:
我需要用 email.csv 中的电子邮件地址覆盖 userinfo.csv 中的电子邮件值 userid 和 u_user 值在两个 csv 中都匹配且唯一。 userinfo.csv 中的 email 地址值不好,需要用 email.csv 中的 email 值覆盖。
如何匹配 csv 和附加电子邮件值中的用户 ID?
甚至不知道从哪里开始。请帮忙。
email.csv
userid,email
1234,user4@email.com
1235,user5@email.com
userinfo.csv
u_work,u_user,u_address,u_city,u_state,u_zip,u_email,u_phonehome
1234,here,there,everywhere,55555,1234@bad.org,555-555-5555
away,1235,there,here,everywhere,66666,1235@bad.com,666-666-6666
new.csv
u_work,u_user,u_address,u_city,u_state,u_zip,u_email,u_phonehome
1234,here,there,everywhere,55555,user4@email.com,555-555-5555
away,1235,there,here,everywhere,66666,user5@email.com,666-666-6666
【问题讨论】:
-
请根据@Bacon Bits 评论/确认/更新您问题中的
userinfo.csv:“您提供的 CSV 无效”。 -
您可以使用来自PowerShell Gallery 的
[Join-Object] cmdlet:Import-CSV .\userinfo.csv | LeftJoin (Import-CSV .\email.csv) userid {$Right.$_} | Export-CSV .\New.csv
标签: powershell