In a datatable, I want to get words that only be included in “0” value.
on that case, answers are “Banana”, “mandarine”
Here is more detail
Pick values “0” matched word combinations.
ex) apple banana grape, banana, apple grape, grape, apple mandarine
in that combinations, Delete words that in other “not 0” cells.
ex) apple(x) banana grape(x), banana, apple(x) grape(x), grape(x), apple(x) mandarine
=> banana, banana,mandarine
=> banana, mandarine (delete duplicated)
Please explain more on logic which word to select, as in your example “Apple Banana grape”, “Banana”, “Apple grape” and “grape” have zero value but you select only “Banana” and “Mandarine”. Why not others ?
We do not use CoptToDataTable when we can expect also an empty filter result. In such case CopyToDataTable will throw an exception. FirstOrDefault will return null in the case no matching row was found.
Pick values “0” matched word combinations.
ex) apple banana grape, banana, apple grape, grape, apple mandarine
in that combinations, Delete words that in other “not 0” cells.
ex) apple(x) banana grape(x), banana, apple(x) grape(x), grape(x), apple(x) mandarine
=> banana, banana,mandarine
=> banana, mandarine (delete duplicated)
Prepare the Splitted Datatable row data based on the word combination column. So that we will have individual words in each row of word combination as the operation also needs to be performed in the same way. We can use the below expression to perform it.
OutputDT = (From x In DT.AsEnumerable
Let splitData = Split(x("word combination").ToString).ToArray
From s In splitData
Select OutputDT.Rows.Add(s,x("value").ToString)).CopyToDataTable
Here, DT is the input Datatable variable and OutputDT is the clone of the Input datatable.
Next, we can Perform Group By on word combination column and Filter based on the value column to select only those row groups where all the values are 0.
Omg Omg Omg!!
your solution was totally worked and explanation was also impressive.
So thankful .
If we are in same country, I would like buy some drink.