Problem with empty datarow

hello everyone,
I am reading an excel file with the range in the read range A1:F100 as the file has repeated columns that I do not need for the purpose of the process.

The Datatable, if I print it, comes up empty (there are no rows valued in the file), but from the DT.Rows.Count comes up 99 rows.

When I try to delete the empty rows with the following query.
DataTableName=DataTableName.Rows.Cast(Of DataRow)().Where(Function(row) Not row.ItemArray.All(Function(field) field Is DBNull.Value Or field.Equals(β€œβ€))).CopyToDataTable()

It returns the following error:
Source contains no datarows

Instead it works if at least one row is valued.
My goal is to know if there are empty or valorized rows, and to handle the valorized ones, how do I actually remove the empty rows?

Hi @Kumar802 ,

Could you maybe provide us with Some screenshots of the workflow or the Data by Debugging ?

Are all the row values Empty or is there data in it ?

A Sample of the excel file that is being used could help us in suggesting a better approach/correction.

Hi @supermanPunch ,

this is the datatable output, as you see it is empty but there are 99 rows present (doing dt.rows.count)
image

At this point if I try to delete the blank rows with the query written in the first message, it goes into error as:

source contains no datarows

I have no problem instead if at least one of the rows is populated (in that case the datatable has 1 full row and 98 empty rows, which it deletes correctly)

@Kumar802 ,

The Query gives out an Error if there are no Non-Empty rows present, This is because it is trying to convert empty rows into a Datatable Directly. Instead we could first convert the Filtered rows into an Array/List and then Convert to Datatable if rows exist in the Array. A detailed explanation is provided in the below Tutorial Post :

Hi @Kumar802

If it helps you can use an filter datatable activity and delete the rows with all the columns empty

Hi,

Is this same topic as the following?

Regards,

1 Like

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