Question

Say I have two csv files

Old.csv

name,place,value

abc,us,1

new.csv

name,place,value

xyz,us,2

abc,us,1

output

name,place,value

xyz,us,2

Compare-Object -ReferenceObject (import-csv -path old.csv | select -exp name) -DifferenceObject (import-csv -path new.csv | select -exp name)

With this code, I'm not sure how and where the new output(the difference) is written. Thanks

Was it helpful?

Solution

Even simpler than that probably.

$Old = Import-CSV Old.csv
$New = Import-CSV New.csv

$New | ?{$Old -notmatch $_} | Export-CSV Output.csv -notype

Output is:

name                          place                         value
----                          -----                         -----
xyz                           us                            2

That work for you?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top