jagreygoose

Manipulating Csv's 1

Jun 12th, 2014
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #     Merge two csv's around a shared column containing unique values.
  2.  
  3. $csv1 = Import-Csv -Path D:\test1.csv
  4. $csv2 = Import-Csv -Path D:\test2.csv
  5.  
  6.  
  7. $csv2 | ForEach-Object {
  8. $status = $_.Status
  9. $emailkey = $_.Email
  10.  
  11. $csv1 | Where-Object {$_.Email -eq $emailkey} |
  12. Select-Object Users, Email, Group, App, @{n='Status';e={ $status }}}|
  13. Export-Csv -NoTypeInformation -Path D:\workingmerge.csv
Advertisement
Add Comment
Please, Sign In to add comment