Data360 Analyze

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

Here are some useful links where you can find more information:

Product Announcements  Product Documentation  Ideas Portal

Discussions

Members

Resources

Events

 View Only
  • 1.  "where" brainscript functionality in Python

    Posted 05-11-2018 06:46

    Hello,

    I am still in the process of transitioning my brain from brainscript to Python. In brainscript, I used the Transform node the most and took advantage of the "where" functionality to restrict the output based on some calculation. Today, I find myself setting up the calculation in a Transform node, outputting a "flag" column, and then filtering out the un-wanted output in a Filter node based on that "flag". It seems not very efficient so I wanted to reach out and ask if there is a better way to program the "where" using Python into the Transform node.

     

    Thanks!

    Rodi



  • 2.  RE: "where" brainscript functionality in Python

    Employee
    Posted 05-11-2018 07:11

    You simply use an IF statement to control the output:

    Make sure that you nest ALL output references under that IF statement.

    if myCondition:
           out1 += in1 
           out1['myField'] = somevalue



  • 3.  RE: "where" brainscript functionality in Python

    Employee
    Posted 05-11-2018 07:38

    You will also need to ensure that the condition also handles Null values.

    There are some other examples of filtering shown in the default ProcessRecords script displayed when the Transform node is added to the canvas. Also see the examples shown in the Transform node online help, which show the effect of setting the output record to None and the use of the implicit write mode.


    You may also be interested in the Migrating to Dataverse guide which covers scripting and other differences between Dataverse and the Lavastorm LAE product:


    https://installers.lavastorm.com/Dataverse320/Migrating+to+Dataverse.pdf


    In addition, a useful way understanding the Python code is to look at the automatically generated code in the Advanced tab of the Filter node once some filter criteria have been specified using the filter grid editor.

     

    Regards,

    Adrian

     



  • 4.  RE: "where" brainscript functionality in Python

    Employee
    Posted 05-11-2018 07:45

    The is also a Dataverse Python module some 'Null safe' functions available for comparisons and string manipulation, see the help in this topic:  Python scripting > Python module support

    The topic is also available online here:

    https://d3sa-preview.infogixsaas.com/docs/dist/help/Default.htm#f-script/python/python-modules.htm