HELP! how can i filter a datatable when a column is a string

Hello guys!
Let me explain what I did first.
I’m using a csv reading activity and getting the result.
After that, I realised that the column I want is as a string, but I needed it to be a Double, so I converted it to Double.
But the Filter DataTable activity won’t let me get the values >= 10, I don’t know why but it always returns a blank csv, what can I do?

The column before my changes.
image
After:
image

1 Like

@joaovictor,

Use this LINQ to get the amount column >=10

(From row In inputDataTable.AsEnumerable()
Let amountDouble = Double.Parse(row("Amount").ToString())
Where amountDouble >= 10
Select row).CopyToDataTable()

Change column name as per your datatable.

Thanks,
Ashok :slight_smile:

1 Like

@ashokkarale tks for helping me,
if you don´t mind, could you tell me how do i use this LINQ, i´m kinda new with UiPath

Hi @joaovictor

=> Use Read CSV activity to read the CSV file and store the output in a variable say dtInput

=> Use the below syntax in Assign activity:

FilteredDt = dtInput.AsEnumerable.Where(Function(x) Cdbl(x("column name").ToString)>=10).CopyToDataTable()

Note: FilteredDt is of DataType System.Data.DataTable. Please change the column name according to yours

=> Use Write CSV activity to write the FilteredDt back to excel.

Hope it helps!!

1 Like

@joaovictor,

Sure!

Use like this. inputDataTable would be your datatable from CSV file.

dtOutput is of datatype Datatable

Sample xaml.
Workflow2.xaml (7.2 KB)

Thanks,
Ashok :slight_smile:

1 Like

Thanks @ashokkarale and @Parvathy you´re amazing!!!

1 Like

Hi @joaovictor

If the query is working please mark my post as solution to close the loop

Happy Automation!!

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