Skip to main content
Question

python

  • October 2, 2019
  • 1 reply
  • 11 views

terezia86
Forum|alt.badge.img

Hi,

can someone help me with the Python expression, please...

I need to get a summary of "sum A" and "Sum B"

wenn I write: "sum A"+"sum B" I get an result: "sum Asum B"

theese "sum A" and "sum B" must be written as a string, because I get this sum from calculating a few fields.

 

 

1 reply

david_r
Celebrity
  • October 2, 2019

If you have two attributes entering a PythonCaller named "sum A" and "sum B" containing numbers, you can do

sum_a = float(feature.getAttribute('sum A') or 0)
sum_b = float(feature.getAttribute('sum B') or 0)
feature.setAttribute('total', sum_a + sum_b)

This will output a new attribute 'total' that contains the sum of these two numbers.

If this is not what you mean, we need a bit more context.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings