Wildcards in array.contains and datatable.select

Hi,

Point 1:
I’m trying to find a certain value in a scraped data table. If the data table contains this value certain actions need to be done. But for some reason it doesn’t work.
In the annotation you can see the one that does work, but if I removed the year, which can vary, it doesn’t work anymore.
If I understand correctly: Contains is a .net code and doesn’t need a * (tested with wildcard * but doesn’t work either).

Point 2:
In the expression below the wildcard does not work either, how can I fix this one as well?
ExtractDataTable.Select("[Column1]=‘Werknemers (2014)’").ElementAt(0)(“Column2”).ToString

Hi,

Can you try the following expression?

Point1 (If condition)

rowT.ItemArray.Any(function(x) x.ToString.Contains("Werknemers"))

Point2

ExtractDataTable.AsEnumerable.Where(function(r) r("Column1").ToString.Contains("Werknemers")).Select(function(r) r("Column2").toString).First.ToString

Regards,

2 Likes

Hello,

Point 1:
The first one seems to work flawlessly, can you explain this part so I can understand for future reference: .Any(function(x) x.ToString.Contains

Point2: I get an error regarding .AsEnumerable not being a member of system.data table.

1 Like

Hi Yoichi,

It actually worked after applying this solution:

Would you care to explain the logic behind your expressions? :slight_smile: I would really appreciate it. Either way, thank you very much!

1 Like

Hi,

can you explain this part so I can understand for future reference: .Any(function(x) x.ToString.Contains

Any method is in LINQ, and function(x) x… is expression of anonymous function in vb.net.
This Any method return true if one or more expression for each item of collection returns true. In this case, each item of rowT.ItemArray will be assigned to x, then evaluated as x.ToString.Contains(“Werknemers”) one by one.

It actually worked after applying this solution:

Great to hear!

Regards,

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.