Reading data from datatable and using linq query for filtering empty rows

I am using below linq query in assign activity for filtering empty rows but it’s not working ;

(From row In dt_input_file_toronto.AsEnumerable()Where Not row.ItemArray.All(Function(Model)Model Is DBNull.Value Or Model.Equals(“”))Select row).CopyToDataTable()

Can anybody assist why it’s not working
Any suggestion what is not correctly memtioned in above query

Thanks in Advance !!

Hi @mittal.abhishek066

Try this

(From row In dt_input_file_toronto.AsEnumerable()
Where Not row.ItemArray.All(Function(Model) Model Is Nothing OrElse String.IsNullOrEmpty(Model.ToString().Trim()))
Select row).CopyToDataTable()

1 Like

Hi @mittal.abhishek066

Can you try this:

(From row In dt_input_file_toronto.AsEnumerable() Where Not row.ItemArray.All(Function(model) model Is DBNull.Value Or model.ToString().Trim().Length = 0) Select row).CopyToDataTable()

Hope this helps,
Best Regards.

1 Like

@arjunshenoy Thanks for the solution !!

It’s working but it’s also consider column name also let say if i am having a 10 rows in excel then its uploading 11 row . 1 row as column name which is not required

1 Like

@Nitya - Thanks for providing the solution.

Its uploading the column name also which is not required . If u have a solution for this then let me know

Thanks…

@mittal.abhishek066

If you don’t want the column names to be added to the excel file, uncheck the AddHeaders option while writing the data table into the file.

image

Hope this helps,
Best Regards.

I am uploading the data into the queue on orchestrator on the basis of column name then reading rows in Performer like specificcontent.(“Columnname”).to string

Can you try this

dt_input_file_toronto = dt_input_file_toronto.AsEnumerable().Where(Function(row) Not row.ItemArray.All(Function(Model) field Is DBNull.Value Or Model.Equals(“”))).CopyToDataTable()

Yeah tried this but no luck same status…

Hey I f iam giving the another column name like PART ID in double quotes

dt_input_file_toronto.AsEnumerable().Where(Function(row) Not row.ItemArray.All(Function(“PART ID”) “PART ID” Is DBNull.Value Or “PART ID”.Equals(“”))).CopyToDataTable()

It should work but it’s saying indentifier expected…

There was syntax errors in the code, use this

dt_input_file_toronto.AsEnumerable().Where(Function(row) Not row.Item(“PART ID”) Is DBNull.Value Or row.Item(“PART ID”).Equals(“”)).CopyToDataTable()

2 Likes

Is it worked for you?

let me check and revert on this.

Thanks @Nitya1

It’s working in “Model” column it was taking blank values also , but with PART ID its working as expected.

Cheers
Happy Automation :slight_smile:

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