Value of Cell's in a Datatable

Hello. I need some help getting value of cell in each column if they are false or true. Each datatable result could be different and results could be 1 column or several columns. Please see example below. Everytime the bot runs, the datatable results could be different in the first row and the values of each row (True, False) could change as well. I wanted to run a loop to see which TV channel has false value and use that TV station. For example if TSN is False then I want to use that cell value and if its True then ignore it.

TSH CBC MTV GLOBAL CTV YTV MUCH TSC
False True False False True False True True

Hope this makes sense.

Hi,

Can you share specific input and expected output? It’s no problem if dummy data.

Regards,

Hi @Rahim_Bhatia
Since you said you want to get values from cells, I suppose you’re working with excel sheets and everytime you run the process you could have one or multiple columns in that excel sheet.

Also I suppose your excel datatable have two rows one header and a row of data.

With that in mind, I suggest you use “read range” activity with the property “add headers” checked, after that loop through every column (dt.Columns) using for each activity with the item type dataColumn, then whenever you find a False
Boolean.Parse(dt.Rows(0)(item.ColumnName).ToString)
add the channel to a list using the add to collection activity

At the end loop through your list and apply your actions.

Find the workflow below where you just need to put your Excel path and sheet name, it will do the rest.

Main.xaml (10.4 KB)

hope that helps.
Regards,
Reda

TVTrueFalse.xlsx (8.7 KB)

The input would be if a specific household has cable and few channels. Output would be channel names and value of true and false if they have it or not. I want to capture both the channel name and the value associated with it. For example I want to see which channels are false and if the value is false, take the channel name and use that to compare with another datatable.

Let me know if this is clear. Thanks

Hi,

Do you need array of channel name which is False in row#0? If so, the following will work.

dt.Columns.Cast(Of DataColumn).Where(Function(c) Not Boolean.Parse(dt.Rows(0).Item(c).ToString)).Select(Function(c) c.ColumnName).ToArray()

Sample20220328-2.zip (8.8 KB)

Regards,

Thank you so much. I was able to follow what you had recommended and got the results I wanted.

1 Like

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