I need a simply file compare of 2 files with no headers, but the 5th column in both files contains a value that has dates, and the 1st,2nd,3rd columns have values that can correlate to entity,account,subacct that also could be used for uniqueness. I tried to use this script but didn't produce the results expected. I would just like a 3rd file showing diff's.
Thanks
Clear-Host
$strReference = Get-Content "c:\glrepts\detail.augfinal.txt"
$strDifference = Get-Content "c:\glrepts\detail_pm.txt"
Compare-Object -referenceObject $strReference -differenceObject $strDifference `
-syncWindow 100 -includeEqual
September 3, 2021 at 1:12 pm
I need a simply file compare of 2 files with no headers, but the 5th column in both files contains a value that has dates, and the 1st,2nd,3rd columns have values that can correlate to entity,account,subacct that also could be used for uniqueness. I tried to use this script but didn't produce the results expected. I would just like a 3rd file showing diff's. Thanks
Clear-Host
$strReference = Get-Content "c:\glrepts\detail.augfinal.txt"
$strDifference = Get-Content "c:\glrepts\detail_pm.txt"
Compare-Object -referenceObject $strReference -differenceObject $strDifference `
-syncWindow 100 -includeEqual
You've provided a requirement, but not asked any questions.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
September 3, 2021 at 1:28 pm
How do you turn the above script into my requirement.
Thx.
September 3, 2021 at 1:58 pm
Well why are you using -includeequal if you just want the diffs 🙂
September 3, 2021 at 2:32 pm
Maybe that's what I'm trying to ask, how do I only show diff's based upon columns that could be used for sort or key.
Thanks.
September 3, 2021 at 3:02 pm
Compare-Object is comparing the entire object, in the case of files it'll compare the entire line and you'll see all the lines that are in one file or the other. Powershell is not ideal for doing column based compares.
September 3, 2021 at 3:26 pm
Any suggestions?
Well this is a SQL forum 🙂 So load it to a database and do a full outer join on what you consider the key columns, then you can do whatever other compares/sorts you need.
September 3, 2021 at 3:38 pm
sounds like a plan.
Thx.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply