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.  Get record column1 that is not Null and output in Column2

    Employee
    Posted 06-13-2018 03:39

    Hi, Dataverse experts,

    I am new to Dataverse and Python and encounter some problems with a simple script. I have a list of missing records. I'm trying to fill the gaps with the value of the previous row.

    Can someone take the time and help me out?

    I'm looking for a way to get the record in column1 that is not Null and to output it in the second column to the point there is a value in column1. Column1 (row 1) to output to Column test row (1 to 5) and the record in Column1 (row 6) to output to Column test row (6 to 10). My code so far: 

    if fields.Date is not Null:
      out1.test= fields.Column1
    else:
      out1.test = 1 (this needs to be the value in column1) .


    Thanks in advance Dino



  • 2.  RE: Get record column1 that is not Null and output in Column2

    Employee
    Posted 06-15-2018 06:39

    You could use the following code in a Transform node (it assumes your input field and output field are both string data types as per your screenshot and defaults to using 1st January 1900 if the first record has a Null value):

     

    #### ConfigureFields property script

    out1 += in1
    out1.test = str

     

    #### ProcessRecords property script

    if node.firstExec:
      previousValue = '1900-01-01'

    if fields.Column1 is not Null:
      out1.test = fields.Column1
      previousValue = fields.Column1
    else:
      out1.test = previousValue

     



  • 3.  RE: Get record column1 that is not Null and output in Column2

    Employee
    Posted 06-15-2018 10:25

    Hi Adrian, 

    thanks, I had already seen the firstExec node but could not get it to work (could not find enough information and the online documentation gives a timeout). 

    Thanks again
     
    Dino


  • 4.  RE: Get record column1 that is not Null and output in Column2

    Employee
    Posted 06-18-2018 01:19

    Hi Dino,

    The second sample code snippet in the ProcessRecords script of the Transform node includes an example of using the node.Exec() method.

    I believe there was an issue with the link to the online version of the help for a short while that has been resolved. The online help documentation is for the server also covers the Python scripting topics and is available here.

    Regards,

    Adrian