RFE: Merge DAT callback

Sometimes replace-cells-by-row merging needs to be done more fine-grained. The current merge options just replaces the value with the 2nd (or later) inputs. This RFE is for a callback that allows the user to specify which value to take, e.g.

def replaceRow(dat, existingRow, newRow):
    return newRow

So now the user can decide whther to keep existing, use new, or something in between, e.g.

def replaceRow(dat, existingRow, newRow):
  existingKeyVal = int(existingRow[1].val)
  newKeyVal = int(newRow[1].val)

  if newKeyVal >= existingKeyVal :
    return newRow
  else:
    return existingRow

This would only replace the row if the new row’s “key value” (column 1) is greater than what it replaces.

Hi @antoinedurr,

interesting, the current Merge DAT approach is to replace cells by comparing the column or row headers. Your proposition almost calls for a more detailed Replace DAT.

For now, and as the needs are particularly specific, could a Script DAT be the best approach?

def onCook(scriptOp):
	scriptOp.clear()

	input1 = scriptOp.inputs[0]
	input2 = scriptOp.inputs[1]
	for i, row in enumerate(input1.rows()):
		in1Row = row
		in2Row = input2.row(i)

		output = in1Row
		if in2Row:
			if in1Row[0] <= in2Row[0]:
				output = in2Row

		scriptOp.appendRow(output)

	return

cheers
Markus

Yes, of course, that’s how I do it now. I end up using a lot of Script DAT because the existing DAT toolsets fall just a bit short. The RFE is to make the Merge DAT more powerful.

I admit using the Merge DAT might still be limiting as (I assume) that inputs would be processed one at a time, i.e. there wouldn’t be a way to consider a matching row in 3 inputs simultaneously.