Just wondering if there's an easy way to fill null values in one column in an attribute table with values in another column of the same attribute table by just writing a query "just the "null values" to be filled with details I already have in another column".Found this query field 1= sec volt, field 2: Lv connection
def updateValue( !SecVolt!, !LVConnection! ):
if !SecVolt! is None: return !LVConnection!
else: return '0'
but in my case I don't want to replace the value with "0" but with values in another column.
-
Yes I can use field calculator but the query seem not to be working!Bob– Bob2019年09月06日 13:13:33 +00:00Commented Sep 6, 2019 at 13:13
2 Answers 2
All geoprocessing tools honour selections. So simply select the rows where column 1 has the NULL values then run a field calculate and select the field you want the values to come from. As you have a selection only those rows will be updated. Absolutely no code required.
-
+1 because this applies to scores of similar questions. Minimize use of coding is also right, too much bias lately.FelixIP– FelixIP2019年09月06日 21:08:09 +00:00Commented Sep 6, 2019 at 21:08
With python parser try:
Code block:
def updateValue(field1, field2):
if field1 is None:
return field2
else:
return '0'
Call with:
realfieldname1=
updateValue(!realfieldname1!,!realfieldname2!)
When you call the function you must use the real fieldname enclosed in !!
-
Tried doing it this way still didn't work. here is what i tried: field 1= sec volt, field 2: Lv connection <def updateValue( !SecVolt!, !LVConnection! ): if !SecVolt! is None: return !LVConnection! else: return '0'>Bob– Bob2019年09月06日 13:51:07 +00:00Commented Sep 6, 2019 at 13:51
-
Edit your question and add the code you try with. Are you sure the field you are calculating is string/text type? Otherwise
return '0'
should bereturn 0
Bera– Bera2019年09月06日 14:05:21 +00:00Commented Sep 6, 2019 at 14:05 -
Thanks for your response, that might be the issue why i'm getting error response. one is a "string type" and one is a "long type" and the other table was brought in through a join relationship....so I'm trying to just bring it in without any join relationship to see if it works.Bob– Bob2019年09月06日 14:12:24 +00:00Commented Sep 6, 2019 at 14:12
Explore related questions
See similar questions with these tags.