Compare two lists in Powershell
I have just started working on powershell. I have two lists of 132 and 134 records each. They have 85 records in common and I want to get the values which are in list1 but not in list2 in a seperate list say list_out1 and the values which are in list2 but not in list1 in another list say list_out2. I finally want to print list_out1 and list_out2. I tried to do as given in this answer but it is giving me all the values in list1 while trying to print list_out1. Also, I have tried using foreach loop and if condition as below and it is also giving me all the values in list1 to print list_out1.
foreach ($i in $list1)
if($list2 -notcontains $i)
$i
I don't know where am I doing wrong. The logic seems to be alright for me. Correct me if I am wrong.
powershell scripting powershell-v3.0
add a comment |
I have just started working on powershell. I have two lists of 132 and 134 records each. They have 85 records in common and I want to get the values which are in list1 but not in list2 in a seperate list say list_out1 and the values which are in list2 but not in list1 in another list say list_out2. I finally want to print list_out1 and list_out2. I tried to do as given in this answer but it is giving me all the values in list1 while trying to print list_out1. Also, I have tried using foreach loop and if condition as below and it is also giving me all the values in list1 to print list_out1.
foreach ($i in $list1)
if($list2 -notcontains $i)
$i
I don't know where am I doing wrong. The logic seems to be alright for me. Correct me if I am wrong.
powershell scripting powershell-v3.0
If the logic is right, then your types are wrong. What kind of records are they? Whatever it is, two things which appear the same are not comparing as the same thing - the typical PowerShell beginner mistake is to want strings or ints, but get PSCustomObjects by doing something likeget-childitem | select name
orget-childitem | ft name
instead of the more correctget-childitem | select -expandproperty name
..
– TessellatingHeckler
Nov 15 '18 at 7:15
What types are your lists / records? Mind that two object instances are treated as different, even if they might have the same property values.
– marsze
Nov 15 '18 at 8:39
@TessellatingHeckler, How should we deal if there are a slight variations in each record in those lists i mean, one list has value 'ABC' and the other list has 'aB.C'. But I want my function to treat both of same. How do we do data cleaning and perform the required comparision?
– Sree
Nov 15 '18 at 19:57
or data something like this $List1 = 'Hello','World2','Today','FromList1' $List2 = 'Hello1','World','Todayi','FromList2' compare $List1 $list2
– Sree
Nov 15 '18 at 20:46
@Sree you'll need to be very clear about what "data cleaning" means. Removing numbers and punctuation would be easy enough ($text -replace 'W')
will do it. and PowerShell ignores uppercase/lowercase when doing comparisons, so that's OK. But what is the rule whereToday
matchesTodayi
? That's going past "data cleaning" and into "spell checker" or "dictionary lookup with probabilities" or "natural language processing magic"...
– TessellatingHeckler
Nov 16 '18 at 10:23
add a comment |
I have just started working on powershell. I have two lists of 132 and 134 records each. They have 85 records in common and I want to get the values which are in list1 but not in list2 in a seperate list say list_out1 and the values which are in list2 but not in list1 in another list say list_out2. I finally want to print list_out1 and list_out2. I tried to do as given in this answer but it is giving me all the values in list1 while trying to print list_out1. Also, I have tried using foreach loop and if condition as below and it is also giving me all the values in list1 to print list_out1.
foreach ($i in $list1)
if($list2 -notcontains $i)
$i
I don't know where am I doing wrong. The logic seems to be alright for me. Correct me if I am wrong.
powershell scripting powershell-v3.0
I have just started working on powershell. I have two lists of 132 and 134 records each. They have 85 records in common and I want to get the values which are in list1 but not in list2 in a seperate list say list_out1 and the values which are in list2 but not in list1 in another list say list_out2. I finally want to print list_out1 and list_out2. I tried to do as given in this answer but it is giving me all the values in list1 while trying to print list_out1. Also, I have tried using foreach loop and if condition as below and it is also giving me all the values in list1 to print list_out1.
foreach ($i in $list1)
if($list2 -notcontains $i)
$i
I don't know where am I doing wrong. The logic seems to be alright for me. Correct me if I am wrong.
powershell scripting powershell-v3.0
powershell scripting powershell-v3.0
edited Nov 15 '18 at 8:37
marsze
5,92132042
5,92132042
asked Nov 15 '18 at 6:41
SreeSree
1077
1077
If the logic is right, then your types are wrong. What kind of records are they? Whatever it is, two things which appear the same are not comparing as the same thing - the typical PowerShell beginner mistake is to want strings or ints, but get PSCustomObjects by doing something likeget-childitem | select name
orget-childitem | ft name
instead of the more correctget-childitem | select -expandproperty name
..
– TessellatingHeckler
Nov 15 '18 at 7:15
What types are your lists / records? Mind that two object instances are treated as different, even if they might have the same property values.
– marsze
Nov 15 '18 at 8:39
@TessellatingHeckler, How should we deal if there are a slight variations in each record in those lists i mean, one list has value 'ABC' and the other list has 'aB.C'. But I want my function to treat both of same. How do we do data cleaning and perform the required comparision?
– Sree
Nov 15 '18 at 19:57
or data something like this $List1 = 'Hello','World2','Today','FromList1' $List2 = 'Hello1','World','Todayi','FromList2' compare $List1 $list2
– Sree
Nov 15 '18 at 20:46
@Sree you'll need to be very clear about what "data cleaning" means. Removing numbers and punctuation would be easy enough ($text -replace 'W')
will do it. and PowerShell ignores uppercase/lowercase when doing comparisons, so that's OK. But what is the rule whereToday
matchesTodayi
? That's going past "data cleaning" and into "spell checker" or "dictionary lookup with probabilities" or "natural language processing magic"...
– TessellatingHeckler
Nov 16 '18 at 10:23
add a comment |
If the logic is right, then your types are wrong. What kind of records are they? Whatever it is, two things which appear the same are not comparing as the same thing - the typical PowerShell beginner mistake is to want strings or ints, but get PSCustomObjects by doing something likeget-childitem | select name
orget-childitem | ft name
instead of the more correctget-childitem | select -expandproperty name
..
– TessellatingHeckler
Nov 15 '18 at 7:15
What types are your lists / records? Mind that two object instances are treated as different, even if they might have the same property values.
– marsze
Nov 15 '18 at 8:39
@TessellatingHeckler, How should we deal if there are a slight variations in each record in those lists i mean, one list has value 'ABC' and the other list has 'aB.C'. But I want my function to treat both of same. How do we do data cleaning and perform the required comparision?
– Sree
Nov 15 '18 at 19:57
or data something like this $List1 = 'Hello','World2','Today','FromList1' $List2 = 'Hello1','World','Todayi','FromList2' compare $List1 $list2
– Sree
Nov 15 '18 at 20:46
@Sree you'll need to be very clear about what "data cleaning" means. Removing numbers and punctuation would be easy enough ($text -replace 'W')
will do it. and PowerShell ignores uppercase/lowercase when doing comparisons, so that's OK. But what is the rule whereToday
matchesTodayi
? That's going past "data cleaning" and into "spell checker" or "dictionary lookup with probabilities" or "natural language processing magic"...
– TessellatingHeckler
Nov 16 '18 at 10:23
If the logic is right, then your types are wrong. What kind of records are they? Whatever it is, two things which appear the same are not comparing as the same thing - the typical PowerShell beginner mistake is to want strings or ints, but get PSCustomObjects by doing something like
get-childitem | select name
or get-childitem | ft name
instead of the more correct get-childitem | select -expandproperty name
..– TessellatingHeckler
Nov 15 '18 at 7:15
If the logic is right, then your types are wrong. What kind of records are they? Whatever it is, two things which appear the same are not comparing as the same thing - the typical PowerShell beginner mistake is to want strings or ints, but get PSCustomObjects by doing something like
get-childitem | select name
or get-childitem | ft name
instead of the more correct get-childitem | select -expandproperty name
..– TessellatingHeckler
Nov 15 '18 at 7:15
What types are your lists / records? Mind that two object instances are treated as different, even if they might have the same property values.
– marsze
Nov 15 '18 at 8:39
What types are your lists / records? Mind that two object instances are treated as different, even if they might have the same property values.
– marsze
Nov 15 '18 at 8:39
@TessellatingHeckler, How should we deal if there are a slight variations in each record in those lists i mean, one list has value 'ABC' and the other list has 'aB.C'. But I want my function to treat both of same. How do we do data cleaning and perform the required comparision?
– Sree
Nov 15 '18 at 19:57
@TessellatingHeckler, How should we deal if there are a slight variations in each record in those lists i mean, one list has value 'ABC' and the other list has 'aB.C'. But I want my function to treat both of same. How do we do data cleaning and perform the required comparision?
– Sree
Nov 15 '18 at 19:57
or data something like this $List1 = 'Hello','World2','Today','FromList1' $List2 = 'Hello1','World','Todayi','FromList2' compare $List1 $list2
– Sree
Nov 15 '18 at 20:46
or data something like this $List1 = 'Hello','World2','Today','FromList1' $List2 = 'Hello1','World','Todayi','FromList2' compare $List1 $list2
– Sree
Nov 15 '18 at 20:46
@Sree you'll need to be very clear about what "data cleaning" means. Removing numbers and punctuation would be easy enough (
$text -replace 'W')
will do it. and PowerShell ignores uppercase/lowercase when doing comparisons, so that's OK. But what is the rule where Today
matches Todayi
? That's going past "data cleaning" and into "spell checker" or "dictionary lookup with probabilities" or "natural language processing magic"...– TessellatingHeckler
Nov 16 '18 at 10:23
@Sree you'll need to be very clear about what "data cleaning" means. Removing numbers and punctuation would be easy enough (
$text -replace 'W')
will do it. and PowerShell ignores uppercase/lowercase when doing comparisons, so that's OK. But what is the rule where Today
matches Todayi
? That's going past "data cleaning" and into "spell checker" or "dictionary lookup with probabilities" or "natural language processing magic"...– TessellatingHeckler
Nov 16 '18 at 10:23
add a comment |
3 Answers
3
active
oldest
votes
Using the Compare-Object
is what you are after. Assuming you do $List1.Item
or something similar.
$MissingGroups = Compare-Object -ReferenceObject ($List1) -DifferenceObject ($List2) -Property Item | Where-Object$_.sideIndicator -eq "<="
add a comment |
Do you mean this?
If you just want to the screen, just remove the Out-File stuff.
get the values which are in list1 but not in list2 in a seperate list
say list_out1
$List1 = 'Hello','World','Today','FromList1'
$List2 = 'Hello','World','Today','FromList2'
# get the values which are in list1
ForEach($Item in $List1)
If($List2 -notcontains $Item)
$Item
# Results in the file
FromList1
and the values which are in list2 but not in list1 in another list say
list_out2.
ForEach($Item in $List2)
If($List1 -notcontains $Item)
Out-File -FilePath D:TempListTwo.txt -Append
# Results in the file
FromList2
Why don't you just use Compare-Object?
– bluuf
Nov 15 '18 at 8:51
No disagreement, but the OP wanted to pump to two different files, with individual results, not just a compare. So, just taking the OP at their explicit request.
– postanote
Nov 15 '18 at 20:33
add a comment |
I don't see the proplem you have with the Q&A you linked yourself.
Using the example lists from postanote's good answer and Compare-Object
## Q:Test20181115SO_53313785.ps1
$List1 = 'Hello','World','Today','FromList1'
$List2 = 'Hello','World','Today','FromList2'
compare $List1 $list2
This returns (using alias compare for Copare-Object
and relying on positional parameter 1 for -ReferenceObject and 2 for -DifferenceObject)
InputObject SideIndicator
----------- -------------
FromList2 =>
FromList1 <=
You can use the SideIndicator
to determine to which file the output should be appended.
Compare-Object -ReferenceObject $List1 -DifferenceObject $List2 |
ForEach-Object -Begin
Remove-item '.UniqueToList*.txt'
-Process
if ($_.SideIndicator -eq '<=')
Add-Content -Path '.UniqueToList1.txt' -Value $_.InputObject
else
Add-Content -Path '.UniqueToList2.txt' -Value $_.InputObject
In case of more complex list objects you might use Export-Csv
with the -Append
parameter instead.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313785%2fcompare-two-lists-in-powershell%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Using the Compare-Object
is what you are after. Assuming you do $List1.Item
or something similar.
$MissingGroups = Compare-Object -ReferenceObject ($List1) -DifferenceObject ($List2) -Property Item | Where-Object$_.sideIndicator -eq "<="
add a comment |
Using the Compare-Object
is what you are after. Assuming you do $List1.Item
or something similar.
$MissingGroups = Compare-Object -ReferenceObject ($List1) -DifferenceObject ($List2) -Property Item | Where-Object$_.sideIndicator -eq "<="
add a comment |
Using the Compare-Object
is what you are after. Assuming you do $List1.Item
or something similar.
$MissingGroups = Compare-Object -ReferenceObject ($List1) -DifferenceObject ($List2) -Property Item | Where-Object$_.sideIndicator -eq "<="
Using the Compare-Object
is what you are after. Assuming you do $List1.Item
or something similar.
$MissingGroups = Compare-Object -ReferenceObject ($List1) -DifferenceObject ($List2) -Property Item | Where-Object$_.sideIndicator -eq "<="
answered Nov 15 '18 at 7:01
DrewDrew
1,466418
1,466418
add a comment |
add a comment |
Do you mean this?
If you just want to the screen, just remove the Out-File stuff.
get the values which are in list1 but not in list2 in a seperate list
say list_out1
$List1 = 'Hello','World','Today','FromList1'
$List2 = 'Hello','World','Today','FromList2'
# get the values which are in list1
ForEach($Item in $List1)
If($List2 -notcontains $Item)
$Item
# Results in the file
FromList1
and the values which are in list2 but not in list1 in another list say
list_out2.
ForEach($Item in $List2)
If($List1 -notcontains $Item)
Out-File -FilePath D:TempListTwo.txt -Append
# Results in the file
FromList2
Why don't you just use Compare-Object?
– bluuf
Nov 15 '18 at 8:51
No disagreement, but the OP wanted to pump to two different files, with individual results, not just a compare. So, just taking the OP at their explicit request.
– postanote
Nov 15 '18 at 20:33
add a comment |
Do you mean this?
If you just want to the screen, just remove the Out-File stuff.
get the values which are in list1 but not in list2 in a seperate list
say list_out1
$List1 = 'Hello','World','Today','FromList1'
$List2 = 'Hello','World','Today','FromList2'
# get the values which are in list1
ForEach($Item in $List1)
If($List2 -notcontains $Item)
$Item
# Results in the file
FromList1
and the values which are in list2 but not in list1 in another list say
list_out2.
ForEach($Item in $List2)
If($List1 -notcontains $Item)
Out-File -FilePath D:TempListTwo.txt -Append
# Results in the file
FromList2
Why don't you just use Compare-Object?
– bluuf
Nov 15 '18 at 8:51
No disagreement, but the OP wanted to pump to two different files, with individual results, not just a compare. So, just taking the OP at their explicit request.
– postanote
Nov 15 '18 at 20:33
add a comment |
Do you mean this?
If you just want to the screen, just remove the Out-File stuff.
get the values which are in list1 but not in list2 in a seperate list
say list_out1
$List1 = 'Hello','World','Today','FromList1'
$List2 = 'Hello','World','Today','FromList2'
# get the values which are in list1
ForEach($Item in $List1)
If($List2 -notcontains $Item)
$Item
# Results in the file
FromList1
and the values which are in list2 but not in list1 in another list say
list_out2.
ForEach($Item in $List2)
If($List1 -notcontains $Item)
Out-File -FilePath D:TempListTwo.txt -Append
# Results in the file
FromList2
Do you mean this?
If you just want to the screen, just remove the Out-File stuff.
get the values which are in list1 but not in list2 in a seperate list
say list_out1
$List1 = 'Hello','World','Today','FromList1'
$List2 = 'Hello','World','Today','FromList2'
# get the values which are in list1
ForEach($Item in $List1)
If($List2 -notcontains $Item)
$Item
# Results in the file
FromList1
and the values which are in list2 but not in list1 in another list say
list_out2.
ForEach($Item in $List2)
If($List1 -notcontains $Item)
Out-File -FilePath D:TempListTwo.txt -Append
# Results in the file
FromList2
answered Nov 15 '18 at 8:14
postanotepostanote
4,0472411
4,0472411
Why don't you just use Compare-Object?
– bluuf
Nov 15 '18 at 8:51
No disagreement, but the OP wanted to pump to two different files, with individual results, not just a compare. So, just taking the OP at their explicit request.
– postanote
Nov 15 '18 at 20:33
add a comment |
Why don't you just use Compare-Object?
– bluuf
Nov 15 '18 at 8:51
No disagreement, but the OP wanted to pump to two different files, with individual results, not just a compare. So, just taking the OP at their explicit request.
– postanote
Nov 15 '18 at 20:33
Why don't you just use Compare-Object?
– bluuf
Nov 15 '18 at 8:51
Why don't you just use Compare-Object?
– bluuf
Nov 15 '18 at 8:51
No disagreement, but the OP wanted to pump to two different files, with individual results, not just a compare. So, just taking the OP at their explicit request.
– postanote
Nov 15 '18 at 20:33
No disagreement, but the OP wanted to pump to two different files, with individual results, not just a compare. So, just taking the OP at their explicit request.
– postanote
Nov 15 '18 at 20:33
add a comment |
I don't see the proplem you have with the Q&A you linked yourself.
Using the example lists from postanote's good answer and Compare-Object
## Q:Test20181115SO_53313785.ps1
$List1 = 'Hello','World','Today','FromList1'
$List2 = 'Hello','World','Today','FromList2'
compare $List1 $list2
This returns (using alias compare for Copare-Object
and relying on positional parameter 1 for -ReferenceObject and 2 for -DifferenceObject)
InputObject SideIndicator
----------- -------------
FromList2 =>
FromList1 <=
You can use the SideIndicator
to determine to which file the output should be appended.
Compare-Object -ReferenceObject $List1 -DifferenceObject $List2 |
ForEach-Object -Begin
Remove-item '.UniqueToList*.txt'
-Process
if ($_.SideIndicator -eq '<=')
Add-Content -Path '.UniqueToList1.txt' -Value $_.InputObject
else
Add-Content -Path '.UniqueToList2.txt' -Value $_.InputObject
In case of more complex list objects you might use Export-Csv
with the -Append
parameter instead.
add a comment |
I don't see the proplem you have with the Q&A you linked yourself.
Using the example lists from postanote's good answer and Compare-Object
## Q:Test20181115SO_53313785.ps1
$List1 = 'Hello','World','Today','FromList1'
$List2 = 'Hello','World','Today','FromList2'
compare $List1 $list2
This returns (using alias compare for Copare-Object
and relying on positional parameter 1 for -ReferenceObject and 2 for -DifferenceObject)
InputObject SideIndicator
----------- -------------
FromList2 =>
FromList1 <=
You can use the SideIndicator
to determine to which file the output should be appended.
Compare-Object -ReferenceObject $List1 -DifferenceObject $List2 |
ForEach-Object -Begin
Remove-item '.UniqueToList*.txt'
-Process
if ($_.SideIndicator -eq '<=')
Add-Content -Path '.UniqueToList1.txt' -Value $_.InputObject
else
Add-Content -Path '.UniqueToList2.txt' -Value $_.InputObject
In case of more complex list objects you might use Export-Csv
with the -Append
parameter instead.
add a comment |
I don't see the proplem you have with the Q&A you linked yourself.
Using the example lists from postanote's good answer and Compare-Object
## Q:Test20181115SO_53313785.ps1
$List1 = 'Hello','World','Today','FromList1'
$List2 = 'Hello','World','Today','FromList2'
compare $List1 $list2
This returns (using alias compare for Copare-Object
and relying on positional parameter 1 for -ReferenceObject and 2 for -DifferenceObject)
InputObject SideIndicator
----------- -------------
FromList2 =>
FromList1 <=
You can use the SideIndicator
to determine to which file the output should be appended.
Compare-Object -ReferenceObject $List1 -DifferenceObject $List2 |
ForEach-Object -Begin
Remove-item '.UniqueToList*.txt'
-Process
if ($_.SideIndicator -eq '<=')
Add-Content -Path '.UniqueToList1.txt' -Value $_.InputObject
else
Add-Content -Path '.UniqueToList2.txt' -Value $_.InputObject
In case of more complex list objects you might use Export-Csv
with the -Append
parameter instead.
I don't see the proplem you have with the Q&A you linked yourself.
Using the example lists from postanote's good answer and Compare-Object
## Q:Test20181115SO_53313785.ps1
$List1 = 'Hello','World','Today','FromList1'
$List2 = 'Hello','World','Today','FromList2'
compare $List1 $list2
This returns (using alias compare for Copare-Object
and relying on positional parameter 1 for -ReferenceObject and 2 for -DifferenceObject)
InputObject SideIndicator
----------- -------------
FromList2 =>
FromList1 <=
You can use the SideIndicator
to determine to which file the output should be appended.
Compare-Object -ReferenceObject $List1 -DifferenceObject $List2 |
ForEach-Object -Begin
Remove-item '.UniqueToList*.txt'
-Process
if ($_.SideIndicator -eq '<=')
Add-Content -Path '.UniqueToList1.txt' -Value $_.InputObject
else
Add-Content -Path '.UniqueToList2.txt' -Value $_.InputObject
In case of more complex list objects you might use Export-Csv
with the -Append
parameter instead.
edited Nov 15 '18 at 15:19
answered Nov 15 '18 at 12:52
LotPingsLotPings
20.3k61633
20.3k61633
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313785%2fcompare-two-lists-in-powershell%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If the logic is right, then your types are wrong. What kind of records are they? Whatever it is, two things which appear the same are not comparing as the same thing - the typical PowerShell beginner mistake is to want strings or ints, but get PSCustomObjects by doing something like
get-childitem | select name
orget-childitem | ft name
instead of the more correctget-childitem | select -expandproperty name
..– TessellatingHeckler
Nov 15 '18 at 7:15
What types are your lists / records? Mind that two object instances are treated as different, even if they might have the same property values.
– marsze
Nov 15 '18 at 8:39
@TessellatingHeckler, How should we deal if there are a slight variations in each record in those lists i mean, one list has value 'ABC' and the other list has 'aB.C'. But I want my function to treat both of same. How do we do data cleaning and perform the required comparision?
– Sree
Nov 15 '18 at 19:57
or data something like this $List1 = 'Hello','World2','Today','FromList1' $List2 = 'Hello1','World','Todayi','FromList2' compare $List1 $list2
– Sree
Nov 15 '18 at 20:46
@Sree you'll need to be very clear about what "data cleaning" means. Removing numbers and punctuation would be easy enough (
$text -replace 'W')
will do it. and PowerShell ignores uppercase/lowercase when doing comparisons, so that's OK. But what is the rule whereToday
matchesTodayi
? That's going past "data cleaning" and into "spell checker" or "dictionary lookup with probabilities" or "natural language processing magic"...– TessellatingHeckler
Nov 16 '18 at 10:23