Remove empty cells, rows and columns

Hi @all,

I am facing problem to remove empty rows, cells and columns using LINQ query in UiPath studio. Please help me to fix the issue.

Sample Input:

Expected Output:
image

If anyone know the solution, please share with here.

Thanks in Advance!

@Kaviyarasu_N

If all rows have same number of columns data that is 4 in your case…we can try like this.

(From d In dtinput.AsEnumerable() Where Not(d.itemArray.All(function(x) String.IsNullOrEmpty(x.ToString))) Let ra = d.ItemArray.Where(function(x) Not String.IsNullOrEmpty(x.ToString)).Select(function(x) x.ToString) Select r = Dtoutput.Rows.Add(ra)).CopyToDataTable()

Cheers

2 Likes

@Anil_G

Thanks for quick response. The value could change and position also change (I given as sample input). My aim is remove all empty rows, cells and columns and save value only.

Do you have any idea?

@Kaviyarasu_N

As mentioned value and position can change…but every row should have same number of values…as in your example every row has 4 …so we can acheive it…we have to build the output datatable with 4 columns…if its 5 next time you have to build for 5 columns and so on

Hope this helps

Cheers

@Anil_G
I think there is small gap in requirement. Please check my exact requirement in below

Input

Expecting Output:
image

Note : The values are changed each and every time, nothing is constant here.

@Kaviyarasu_N

I get it…I am just checking if the cell is empty or not but not for any value…

Did you even try that?

Cheers

Hi @Anil_G

As of now I don’t get any proper solution for this issue. Currently I am using For each loop only :frowning:

If you get any potential solution, please let me know.

@Kaviyarasu_N

The above given linq query is for the same.Please try it

Cheers

Facing an error. Please check my screenshot in below

@Kaviyarasu_N

Please use a different datatable for input and output

Cheers

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