Variable Type = Array of [T] DataRow or List of DataRow having blank spaces in Output

Hi everyone

Really appreciate if anyone can help me with this issue.

I have read range of excel activity with below info:

The output of this read range is = DT_file5_data

Then using LINQ expression, I created below multiple assign

ME1_list = DT_file5_data.AsEnumerable.Skip(2).Select(Function(x) DT_File5.Rows.Add(x(“ME1.TYPE”).ToString, x(“ME1.POWER”).ToString, x(“ME1.RPM”).ToString, x(“ME1.SFOC”).ToString, x(“ME1.NOX”).ToString)).ToList.ToArray

ME2_list = DT_file5_data.AsEnumerable.Skip(2).Select(Function(x) DT_File5.Rows.Add(x(“ME2.TYPE”).ToString, x(“ME2.POWER”).ToString, x(“ME2.RPM”).ToString, x(“ME2.SFOC”).ToString, x(“ME2.NOX”).ToString)).ToList.ToArray

The LINQ above is created to combine lets say column ME1.TYPE, ME2.TYPE, etc. Also ME1.POWER, ME2.POWER, etc. Also ME1.RPM, ME2.RPM, etc. Also ME1.SFOC,ME2.SFOC,etc. Also ME1.NOX,ME2.NOX.

To a final Output which is a CSV template file.
All TYPES is supposed to populate column “Eng_Model”
All POWER is supposed to populate column “MCR_load”
All RPM is supposed to populate column “MCR_rpm”
All SFOC is supposed to populate column “Eng_SFOC”
All NOX is supposed to populate column “NOx”

But currently in my Output below which is a Write CSV activity with headers = DT_File5 is having blank rows:


I try using filter datatable trying to remove the blank rows but it still shows the same Output.

Appreciate any feedback and help!

Hi @Irfan_Musa

Can you try this LINQ expression to filter the empty rows:

dt = (From row In dt.AsEnumerable()
                   Where row.ItemArray.Any(Function(field) Not String.IsNullOrEmpty(field.ToString().Trim()))
                   Select row).CopytoDataTable()

Regards

Hi @vrdabberu
Thank you for the help, it works for me. I will to apply to other parts of my automation.
Currently I am still learning more about LINQ. If its not a burdern to you, could you please help to explain what the code you shared does?

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