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.  insert a blank line between groups

    Employee
    Posted 11-26-2014 08:07

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

    Originally posted by: dhrobertson

    hi all,

    I have a set of data which is grouped by a column. I would like to put a blank line between each group item in the data. is there a way I can do this?

    ie. say I have a bunch of data and a column called CARS that I am grouping on. I want to insert a blank line between each car type..... so a blank line inserted between Honda and fiat, blank line between fiat and Mercedes, etc, etc.

    Honda
    Honda
    Honda
    fiat
    fiat
    Mercedes
    ford
    ford
    ford



    thanks

    doug


  • 2.  RE: insert a blank line between groups

    Employee
    Posted 11-26-2014 19:20

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

    Originally posted by: ryeh

    See attachment. Two approaches. The first one only works if you have one column. I basically create a long list (comma separated) of car makes, and then use the 'Expand from List' node. You could tweak it to accommodate multiple fields (create lists for the other fields).

    The second approach is more robust. It utilizes the 'do output' command. For the sake of ease, I assume that the records are already grouped by car make. If not, a 'Sort' node can be used to do the grouping.
    Attachments:
    insBlankRecord.brg


  • 3.  RE: insert a blank line between groups

    Employee
    Posted 11-28-2014 03:29

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

    Originally posted by: dhrobertson

    thanks ryeh,

    with regards the logic where you initially create an output 1 with all the fields etc. and then you say where 1==0... I take it that this has to happen in order to "initialize" the fields so that they can be output again in the "do output" functions later? if you say "where 1==0" that means that it will never actually run but it creates the environment for the later outputs to run successfully? have I understood that correctly?

    I just want to understand that bit of logic as I notice it happens a lot in various graphs I've seen and I would like to get my head around the process.

    thanks

    doug


  • 4.  RE: insert a blank line between groups

    Employee
    Posted 11-28-2014 03:48

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

    Originally posted by: Tim Meagher

    Hi,

    You're exactly right with this being around initialization of the fields.
    It's essentially setting up the way that data will be output and the mappings that will take place in all of the subsequent "do output" statements (unless explicitly overriden in a do output iteration).

    I'm not sure what version of the software you are using, but in the latest release (LAE 5.1) the brainscript help for the "do output" statement has been updated to hopefully clarify this a little.

    From the 5.1 brainscript help for "do output":

    			
    				Used to configure output for a node which is not necessarily based on the input. The statements contained within the do output block will control what is sent to the given output.
    Requirements:
    1. The output on which the do output block operates must have already been defined within the script (using the output operator)
    2. The do output cannot specify an output name - only an output number
    3. All of the fields which are to be output must have been defined via emit statements in the original output statement - no new fields can be defined in the do output block
    4. Only specifically named fields can be used within an emit statement in the do output block - emit pattern, emit * etc cannot be used
    For any fields or variables which are to be sent to the output for each iteration in the do output statement, these can all simply be configured within the output definition. Then, within the do output statement, only the fields which are modified on each iteration need to be configured in the do output statement. In practice, the output statement will generally be constructed with a "where false" option, such that the definition is only defined in the output statement. The records are then only written on each execution of the do output statement.

    Example:
    
    #In the following example, the output is defined to pass through all of the input fields, 
    #along with a "RecordNum" field.
    #The do output statement then specifies that "outputCount" records are to be written - where outputCount is a field on the input.
    #If outputCount is less than equal to zero, no records will be output.
    #Otherwise, for a given input record, "outputRecord" records will be written.
                    
    #Define the output - required prior to using do output
    output 1 {
    
    
        #Pass through all of the input fields
        emit *
    
    
        #Additionally define an output field "RecordNum"
        #but don't actually write the records here
        emit null.int() as "RecordNum" 
            where false 
    }
    
    
    #Now, loop through 'outputCount' times
    i = 0
    while (i < 'outputCount') {
    
    
        #Each time, define to write a record to output 1
        do output 1 {
    
    
            #Write the iteration count as the "RecordNum" field
            emit i as "RecordNum"
        }
        i = i + 1
    }
                
    #In this example, the output statement is defined using the output name ("Data")
    #However the do output statement still operates on the output number.
    #In this example, assume there is an output "Data" which is the second node output
    #Define the output - required prior to using do output 
    output "Data" {
    
    
        #Pass through all of the input fields
        emit *
    
    
        #Additionally define an output field "RecordNum"
        #but don't actually write the records here
        emit null.int() as "RecordNum" 
            where false 
    }
    
    
    #Now, loop through 'outputCount' times
    i = 0
    while (i < 'outputCount') {
    
    
        #Each time, define to write a record to output 2 ("Data")
        do output 2 {
    
    
            #Write the iteration count as the "RecordNum" field
            emit i as "RecordNum"
        }
        i = i + 1
    }