Read range until null/ empty

Hi, I have an Excel, where the black lines are, are data entries. How do I do a read range so that when there is a row with no values, the rest of the rows below are not taken into account?

image

Thanks :slight_smile:

@Karan_Chauhan

Use this

Datatable.AsEnumerable.where(Function(row) row.ItemArray.All(function(col) not string.IsNullOrEmpty(col.ToString))).CopyToDataTable

Gives only the rows which are not empty

Cheers

Hello @Karan_Chauhan

You could read the range as normal, put an if at the very beginning of your loop and if all the columns are blank, simply exit the loop using a break.

Best,

Cam

Hi I don’t want to include rows below the empty row is what I am asking, there will only be one empty row so when this appears I don’t want to keep the rows underneath.

@Karan_Chauhan

After reading the excel we can remove the empty rows

While reading the excel using read range activity how the bot knows which row is empty

Cheers

we do understand:

Assign Activity:
dtSmall =

dtOrig.AsEnumerable.TakeWhile(Function (r)  r.ItemArray.All(Function (c) Not String.IsNullorEmpty(c.toString.Trim))).CopyToDataTable

But we can also implement with essential options like:

For each row in datatable

  • IF Activity: Check if all columns are empty
    • Then: Break activity
    • Else: add row to a second datatable

This error came up:

image

when filter result is empty, then we handle with
:ambulance: :sos: [FirstAid] Handling of The source contains no DataRows exception - News / Tutorials - UiPath Community Forum

but in that case it looks like a total empty datatable is sent to the processing

illustrations for above both:
grafik

AND
Variable: dtFiltered, Default/Init: dtData.Clone


IF: CurrentRow.ItemArray.All(Function (x) String.IsNullOrEmpty(x.toString.Trim))

@Karan_Chauhan

can you replace the old activities and try once

its working fine for me