I have been trying to compare 2 csv files and export the difference to a separate csv file and it is not working properly when I test it, it will give result if there is nothing in the Unique ID column but not when the number is different which is what I need it to.
Heading of CSV files
First Name, Surname, Unique ID, Tags
Current Script:
Comparing 2 CSV files and exporting difference to a separate file
From my testing I have been able to verify what data is being generated from the different parts except from where it gets the data from the $SAS line" If (!($SAS | Where-Object {$_.“Unique ID” -eq $line.“Unique ID”})) ", from the test results I need to make sure that it is getting the correct data to work. I did try the compare-object but could not work it out. Still very new to this.
I tried your script and it did give me different results but not the required end result which was to compare Unique ID from both CSV files and output the difference, So I am learning to understand your script I am presuming that the $_.MemberType cycles through the $Acer file a line at a time or does it search the whole colunm?
to play a little with it you could execute it line by line in a console and analyse the output.
What happens with the first 2 lines is (hopefully) obvious. The third line just extracts the headers from one of your csv files to use it later for the csv export. Otherwise you would have the SideIndicators in your output file.
To make it more visible how it works you can run the following lines in a console window:
if I’m not wrong Lyn asked to get the diferences between the 2 files. So your first example is actually wrong.
Your second example is almost like my last post except of I will have the complete items with all columns of the csv and you only the SideIndicator and the compared property. Right?
to not get any error does not mean the script does what it should! What’s in your ‘D:\test3.csv’ when you had in your csv files what Lyn mentioned in the initial post (Headers: First Name, Surname, Unique ID, Tags)?