LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  How to filter 100s of values using filter node ?

    Employee
    Posted 01-30-2015 11:44

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gauravdb

    Hi,

    This probably sound very silly. But can we use WHERE in filter node to filter values separated by comma ? or some other separator ? same way we use in "in" in SQL

    Reason I am asking is that it is silly to keep writing

    emit *
    where value == 1
    or value == 2
    or value ==3
    ..........
    or value == 100

    Please reply ASAP.

    Thanks
    GK


  • 2.  RE: How to filter 100s of values using filter node ?

    Employee
    Posted 01-30-2015 12:35

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ejones

    The "in" operator does not exist in BRAINscript. I don't know if you could put, "where value >= 1 and value <= 100". I'm guessing that isn't the answer you are needing.

    I have done this before using a regex expression. The syntax is a bit esoteric but also very powerful.
    where str(value).regexIsMatch("^(1|2|3|100)$")


  • 3.  RE: How to filter 100s of values using filter node ?

    Employee
    Posted 01-30-2015 12:47

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Tim Meagher

    Alternatively, you could create a list containing the values you're searching for, and check if the specified value is in the list.

    There are a couple of ways to do this - create the list by specifying all of the values individually, or use a loop if you want values in certain ranges.

    Examples below (first commented out):

    #First approach, specify all values#if (firstExec) then 
    #    outputValues = list(1,2,3,4,5,6,7,8,9,10)
        
    #Second approach, specify by ranges etc
    if firstExec then {
     outputValues = list()
     i=1
     while (i<=10) { 
        outputValues = outputValues.append(i) 
           i=i+1
     }
     i=16
     while (i<=20) { 
        outputValues = outputValues.append(i) 
        i=i+1
     }
    }
    emit *
    where outputValues.find('value') != -1


  • 4.  RE: How to filter 100s of values using filter node ?

    Employee
    Posted 01-30-2015 13:53

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ltolleson

    You can also instead of using a list just use a delimited string with the strFind command.

    if firstexec then
    {
       searchList = "*Yale*Princeton*MIT*Harvard*Columbia*Dartmouth*"
    }
    
    # This searchValue is hard coded in this example, but could be a value from your input data.
    searchValue = "*Harvard*"
    
    emit *
    where searchList.strFindI("searchValue") > -1


  • 5.  RE: How to filter 100s of values using filter node ?

    Employee
    Posted 02-02-2015 03:48

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gauravdb

    Thanks Everyone.

    ejones's Trick worked perfectly. I will try rest of the two as well.

    Thanks a ton again
    GK


  • 6.  RE: How to filter 100s of values using filter node ?

    Employee
    Posted 02-02-2015 07:09

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: stonysmith

    Just to present another option: copy/paste this text into your graph.
    This uses a Lookup node as though it was a filter.
    Using something like this would allow you to move your SearchValues out to an external data source, rather than hard-coding it within your graph.

    node:Lookup
    bretype:core::Lookup
    editor:sortkey=54cf84c350192c84
    input:@40fd2c746abc6dc7/=
    input:@40fd2c74486e4494/=List_of_Values.40fe6c55598828e5
    output:@40fd2c7445835585/=
    prop:InputKey=<<EOX
    Value
    EOX
    prop:LookupKey=<<EOX
    MatchValue
    EOX
    prop:Script=<<EOX
    emit 1:*
    where matchIsFound
    EOX
    editor:XY=330,170
    end:Lookup

    node:List_of_Values
    bretype:core::Static Data
    editor:Label=List of Values
    editor:sortkey=54cf84c952124a53
    output:@40fe6c55598828e5/=
    prop:StaticData=<<EOX
    MatchValue
    1
    2
    3
    4
    20
    31
    100
    EOX
    editor:XY=260,230
    end:List_of_Values