How to Identify if Datatable only has blank row?

Hi all

I have a task with an excel file in a specific column that filled with number. I am able to create a flow that for each row in that column, robot do some tasks and after it finished it will replace the value with blank ("")

image

Please note that sometimes the value will be left blank or it will still has value like this

image

My question: What is the command to enable the robot to determine whether the column has no data? because when i try to count the row on the first picture, it returns 8 row as it treated the blank cell as an actual row so that i couldnt use db is nothing or null.

Thank you

Hi @rookies
Use String.IsNullOrEmpty(row(“Order”).ToString)

Thanks
Ashwin S

1 Like

Hi @AshwinS2 , sorry i would like to edit my question. I am not a native speaker and only realize my mistake after i post it

do i need to assign your command to some variable? or put it in for each?

Hi @rookies
use this query in if condition before that use for each row

Thanks
Ashwin S

1 Like

@AshwinS2

from what I understand, its not what i seek. I want to make the robot determine if whole row on datatable is just empty or null or not (preferably in one go), and then continue the flow based on the result. If I run for each and if, it will only determine row per row.

Do you know what command suits that more?

Thanks

@rookies

For Each row As DataRow In table.Rows
    	Console.WriteLine(row.ItemArray.Any(function(item) String.IsNullOrEmpty(item.ToString)).ToString)
Next

Ussing ItemArray you will get an Object array that contains all the elements from one row

Hi @paul.placintar

Thank you for the answer. it does help me give the output of 8 true according to the case above. however, could you please give me insight about what is the best way to make the robot recognize that the scan result is all true?

If you want to check if the entire columm is empty, you can use the following:

dt1.AsEnumerable.Where(Function(x) Not(String.IsNullOrWhiteSpace(x.Item("YourColumn").ToString))).Count

Replace dt1 with your datatable, and “YourColumn” with the name of your column (keep the double quotes though). This will return an integer that is the total count of all the rows in your datatable that contain values. If it returns 0, that means no rows contain data for that specific column

1 Like

Thank you. that is what i need @Dave

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