Remove row from excel sheet

From attached excel i have to remove rows where
1.Weight with a “0” value
2.Ticker with more than one $ or any ticker 5 characters long ending in XX.
2.xlsx (8.7 KB)

i tried but not working could u share the code in UiPath

Hi @sshitol ,
use read range to get the data into datatable and use below query to filter

use assign activity to achieve this
DataTable = DataTable.Select("NOT (LEN(Ticker) = 5 AND Ticker LIKE '%XX') and Weight>0").CopyToDataTable()

then use write range

Regards,
Arivu

pls share in UiPath workflow

Hi @sshitol

Can you try this

dt = (From row In DT.AsEnumerable()
              Let ticker = row("Ticker").ToString()
              Let weight = Convert.ToInt32(row("Weight"))
              Where weight <> 0 AndAlso Not (ticker.Count(Function(c) c = "$") > 1 OrElse (ticker.Length = 5 AndAlso ticker.EndsWith("XX")))
              Select row).CopyToDataTable()

Input:

Output:

Regards,

hello @sshitol ,

See Below Output is expected output

dt_Input.AsEnumerable().Where(Function(row)  row.Field(Of Double)("Weight") <> 0 AndAlso  Not (row.Field(Of String)("Ticker").Count(Function(c) c = "$"c) > 1 OrElse  (row.Field(Of String)("Ticker").Length = 5 AndAlso row.Field(Of String)("Ticker").EndsWith("XX")))).CopyToDataTable

Main.xaml (8.2 KB)

Regards
Dheerandra Vishwakarma

1 Like

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