How to filter the csv file columns data

In my csv file having the columns named OPEN, CHNG and VALUE I want to filter the data based on the below condition, can anyone please help me on the solution.

OPEN >5000
CHNG should only positive numbers
VALUE > 515974237

Hi @vaibhav2.chavan

Please try filter datatable and configure as below,

image

Thanks

@vaibhav2.chavan

Try below expression.

           OutputDT = InputDT.AsEnumerable.Where(Function(row) Cint(row("OPEN")) > 5000 AND Cint(row("CHNG")) > 0 AND Cint(row("VALUE")) > 515974237).CopyToDataTable

@lakshman - How to use this expression? In which activity I have to use?

Stick with Pratash’s solution using the activity if the expression is not clear.
Effectively they both do the same.

Step 1: read the file using the ‘Read CSV’ activity. The output datatable will contain all your data. Be sure to flag the ‘Has headers’ box.
Step 2: apply any of the solutions posted above.

  • In Prasath’s solution, enter the csv datatable as input. You can use the same datatable as output or create a new one if you want to retain your raw data as well
  • Using the expression* is a simple matter of ‘assign’. Assign to your datatable the expression of Ganta after the = sign. Be sure that the name InputDT matches your CSV datatable.

Step 3: Happy faces, you’re done as far as your request goes.

*Please note the typo in the expression: AsEnumersble should be AsEnumerable :wink:

1 Like

@vaibhav2.chavan

Use Assign activity

Left-hand: OutputDT
Right-hand: InputDT.AsEnumerable.Where(Function(row) Cint(row("OPEN")) > 5000 AND Cint(row("CHNG")) > 0 AND Cint(row("VALUE")) > 515974237).CopyToDataTable

Here, OutputDT is of type System.Data.DataTable and InputDT variable holds input data from Excel file.