Filter Range of numbers from CSV file

Hello world!

Im fairly new to this so bear with me :slight_smile:

Has anybody built a process where a range of numbers is retrieved from a CSV?

For example as follows:

Input Example (CSV data):

ItemA 99
ItemB 49
ItemC 70
ItemD 200
ItemE 101

And from that data (above), numbers in the range of 51-100 are put in a new CSV with the corresponding data.

Output Example (New CSV):

ItemA 99
ItemC 70

Also the search range is dynamic and comes from a input dialog drop down list, so it may be 51-100 or 101-150 or 151-200 and so on.

Thank you!

KR,

Robbie

@RobbieJ
in general it is about:

  • read csv
  • filter data
  • write csv


Variables:
grafik

for the filtering following options are available:

  • filter datatable activity
  • datatableVar.Select method
  • A linq statement

Example:
dtData.Select(String.Format("Convert(No,'System.Int32') >= {0} And [No] <={1} ",Min,Max))

Min, Max are variables with the corresponding borders as Integer32
Convert(No,β€˜System.Int32’) force the conversion of col value into an integer
[No] <= is a short form for defining a filterexpression for a column

String.Format allows us to create a string with the injection of variables

Find starter help here:
CSV_Filter_RangeSegment_Integer.xaml (6.9 KB)
used CSV file:
data.csv.txt (59 Bytes)

Also have a look here:

1 Like

Hi @ppr,

Thank you very much, that was a great explanation!

The only issue is that im still stuck on how to link the option of the minimum and maximum (e.g.51-100) amount to this process, since it can change depending on what is selected.

Does this mean that i have to do the same for all the options on the list below?

This is where the range comes from:

Untitled

Thank you,

-Robbie

@RobbieJ
for this the variables Min, Max come into the picture and needs to be set dynamicly.

For handling different patterns e.g. x-y,<x,>x we can use a switch actvity

Thank you @ppr for taking the time to explain all this.

KR,

-Robbie

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