If DataTable is empty

Hello,

I am pulling data from another spreadsheet and pasting it. I need to accommodate for the off chance that there is no data. My thought was to use the if activity. If there aren’t any rows with data, skip to the next activity, else write range. Any help would be greatly appreciated.

image

Hi,

How about the following expression?

JavaAdvFinalDT is Nothing OrElse JavaAdvFinalDT.Rows.Count =0

image

Regards,

@jenn.cruz

If you are already reading data then you can use the below

IsNothing(JavaAdvFinalDt) OrElse JavaAdvFinalDt.RowCount>0

Cheers

Hi @jenn.cruz ,

Thanks for reaching out UiPath Community.

In Condition of If you can use “JavaAdvFinalDT.Rows.Count =0” Then “Skip to the next activity”
Else “Write Range”

Hope this works for you.

Happy Automation,
@Vinit_Kawle

1 Like

Hi @jenn.cruz

Check out this thread. It might help you.

Regards

Hi @jenn.cruz

Use he below syntax in if condition

JavaAdvFinalDT.Rows.Count = 0

Regards

@jenn.cruz

if condition:

JavaAdvFinalDT.Rows.Count = 0

Cheers!!

You can use data.rowcount
if data.rowcount =0
regards,

Thank you for this. The JavaAdvFinalDT is pulling from the below row count. I added 2 at the end to accommodate for the Tab title A1 and Column title A2. Should I utilize JavaAdvrowcount.toString<=2? If I need to remove the 2 from the end of the formula and place it somewhere else in the code, please let me know.

@jenn.cruz

  1. You can simplify the above one like below…

Dt.AsEnumerable.Where(function(x) IsNothing(x("Region")) OrElse String.IsNullOrEmpty(x("Region").ToString.Trim)).Count + 2

  1. Which checking the if condition you can do advrouwcount-2>0 so that the extra 2 added can be ignored

Cheers

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