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.  Python -- Field Name

    Employee
    Posted 05-12-2016 07:31

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

    Originally posted by: jpstory

    Hi All

    I have the following code to grab the field name for all fields in the node input pin.

    Understood that there are other nodes can perform such task easily, but would particularly like to know how to get it done in Python Node.
    The reason being that there's other logic already coded in this Python node and I just need this piece to work to enhance it:


    I tried .Name thought it might just be that simple but apparently too simplistic. Any ideas?
    Also, just curious, what exactly is InRec, is it a Dictionary Object or just an Array?

    def pump(self, quant):
    while quant.permitsRunning(self):
    inRec = self.inputs[0].read()
    outRec = self.outputs[0].newRecord()

    if not inRec:
    return False

    Size = len(inRec)
    for i in range(Size):
    outRec["Field" + str(i+1)] = inRec[i].name

    self.outputs[0].write(outRec)
    success = self.ProcessWrite(Size)


  • 2.  RE: Python -- Field Name

    Employee
    Posted 05-12-2016 08:10

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

    Originally posted by: stonysmith

    You would use:
    outRec[i] = self.inputs[0].metadata[i][0]