r/PowerShell • u/Dull_Rub_9295 • Nov 24 '25
Compare two slightly different csv files via command line
I am looking to compare two csv files with a key field that is slightly different in one of those files. Below is an example of how the key fields would be different.
file1 PartNo file2 PartNo
123 123-E
3881231234 3881231234-E
1234-1234-1234 1234-1234-12-E
One of the files PartNo always ends with -E and may be truncated before the -E
I have seen the compare-object command but unsure if this can be made to work.
Thanks for any ideas.
0
Upvotes
4
u/[deleted] Nov 25 '25
What have you tried so far?
6
u/faulkkev Nov 24 '25
Import them can do compare object
1
u/charleswj Nov 25 '25
I don't see two different CSVs, can you clarify what would one look like vs the other?
1
u/BlackV Nov 25 '25
If you read this back to your self, would this example be easy for you to understand ?
Is this what you're meaning?
you want to check file 1 and check file to where only the numbers match ?
1
u/Ok_Mathematician6075 Nov 25 '25
Do a foreach with one and a lookup against the other one.
1
u/VoltageOnTheLow Nov 25 '25
"I have seen the compare-object command but unsure if this can be made to work"
Why are you unsure? What have you done?
1
u/jsiii2010 Nov 25 '25
Pick the properties you want to compare:
1
u/Dependent-These Nov 25 '25
If all you have availible is cmd line, check out the filecompare command and availible switches with FC /?