<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Field calculation, concatenation in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/84998#M6708</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;what if you try&lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;if len(unit) &amp;lt; 1:&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Aug 2012 18:06:07 GMT</pubDate>
    <dc:creator>BruceNielsen</dc:creator>
    <dc:date>2012-08-24T18:06:07Z</dc:date>
    <item>
      <title>Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/84993#M6703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've hit a wall with a field calculation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm writing a calculation for a full address field formed by the values of several other string fields. This is what I have:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression = fulladdress(!AddNum!, !Prefix! , !Street! , !Type! , !Suffix! , !Unit!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;def fulladdress(num, prefix, street, sttype, suffix, unit):

# Concatenate fields
&amp;nbsp;&amp;nbsp;&amp;nbsp; # for addresses without unit
&amp;nbsp;&amp;nbsp;&amp;nbsp; if unit:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = num +' '+ prefix+' '+street+' '+sttype+' '+suffix+' #'+unit
&amp;nbsp;&amp;nbsp;&amp;nbsp; # for addresses with unit&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = num +' '+ prefix+' '+street+' '+sttype+' '+suffix

# Remove unwanted spaces
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = fulladd.strip()
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = fulladd.replace('&amp;nbsp; ',' ')
&amp;nbsp;&amp;nbsp;&amp;nbsp; return fulladd&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It works exactly as I expect... except that it ignores the IF statement completely. I've tried several different ways of forming the IF, but none work as expected. My calculated result is always what it should be if there's a value in the unit field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think I've missed something very basic...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 15:36:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/84993#M6703</guid>
      <dc:creator>CFrate</dc:creator>
      <dc:date>2012-08-24T15:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/84994#M6704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There would be a difference if the "unit" field was Null or simply a blank string of ''.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your code should work as is when unit is a Null, however, a blank string of '' is considered a valid value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something like this should take care of both cases:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def fulladdress(num, prefix, street, sttype, suffix, unit):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if unit not in [None, '']:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = num +' '+ prefix+' '+street+' '+sttype+' '+suffix+' #'+unit
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = num +' '+ prefix+' '+street+' '+sttype+' '+suffix
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = fulladd.strip()
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = fulladd.replace('&amp;nbsp; ',' ')
&amp;nbsp;&amp;nbsp;&amp;nbsp; return fulladd&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A tip for you: It is &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;much&lt;/SPAN&gt;&lt;SPAN&gt; easier to deal with and format complex conditional expresions in an UpdateCursor than in the "code block" of the CalculateField tool.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:16:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/84994#M6704</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-10T23:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/84995#M6705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, Chris, but it didn't yield a different result. The results still end in '#' even when there's no unit present.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My reason for going about it in the calculator is that I'm saving it as a .cal file so that my end-users can just load the expression when they need to calculate. It's the easiest option I could think of, since they're familiar enough with the field calculator.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just so we're clear on the desired results,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Given these values:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;num= 101 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;prefix= N&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;street=Main&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sttype=St&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;suffix=''&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;unit=1A&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The calculation should return "101 N Main St #1A"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;But &lt;/STRONG&gt;&lt;SPAN&gt;if the Unit value were not present, then it should just be "101 N Main St"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;With my expression and the one you provided, the result is instead "101 N Main St #"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 17:24:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/84995#M6705</guid>
      <dc:creator>CFrate</dc:creator>
      <dc:date>2012-08-24T17:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/84996#M6706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In your database, what is the field value when there is "no unit field value"?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is it Null, '', ' ', or ?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 17:28:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/84996#M6706</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2012-08-24T17:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/84997#M6707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;In your database, what is the field value when there is "no unit field value"?&lt;BR /&gt;&lt;BR /&gt;Is it Null, '', ' ', or ?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In such a case, it's blank. No space and no nulls (though the field is nullable).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 17:34:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/84997#M6707</guid>
      <dc:creator>CFrate</dc:creator>
      <dc:date>2012-08-24T17:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/84998#M6708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;what if you try&lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;if len(unit) &amp;lt; 1:&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 18:06:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/84998#M6708</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2012-08-24T18:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/84999#M6709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;what if you try&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;if len(unit) &amp;lt; 1:&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Well, that almost worked. Now I have the opposite problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Using len(), the field calculates correctly for records with no value in UNIT, but not those with a value in UNIT.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 18:25:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/84999#M6709</guid>
      <dc:creator>CFrate</dc:creator>
      <dc:date>2012-08-24T18:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85000#M6710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here's to trying a different approach:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def fulladd(num, prefix, street, sttype, suffix, unit):
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = (num + ' ' + prefix).strip()
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = (fulladd + ' ' + street).strip()
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = (fulladd + ' ' + sttype).strip()
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = (fulladd + ' ' + suffix).strip()
&amp;nbsp;&amp;nbsp;&amp;nbsp; if unit.strip() not in ['None','',' ']:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = fulladd + ' #' + unit
&amp;nbsp;&amp;nbsp;&amp;nbsp; return fulladd
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:16:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85000#M6710</guid>
      <dc:creator>BruceBacia</dc:creator>
      <dc:date>2021-12-10T23:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85001#M6711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This version should work for you.&amp;nbsp; It will take care of unwanted leading or trailing spaces&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def fulladd(num, prefix, street, sttype, suffix, unit):
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = ''
&amp;nbsp;&amp;nbsp;&amp;nbsp; for add in [num,prefix,street,sttype,suffix]:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = ''.join([fulladd,' ',add.strip()]).strip()
&amp;nbsp;&amp;nbsp;&amp;nbsp; if unit.strip() not in ['None','']:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = ''.join([fulladd,' #',unit.strip()])
&amp;nbsp;&amp;nbsp;&amp;nbsp; return fulladd
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:16:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85001#M6711</guid>
      <dc:creator>BruceBacia</dc:creator>
      <dc:date>2021-12-10T23:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85002#M6712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here's an even shorter, quicker version.&amp;nbsp; You might want to test this one a little before implementing.&amp;nbsp; I did test it, but not as extensively as the previous one.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def fulladd(num, prefix, street, sttype, suffix, unit):
&amp;nbsp;&amp;nbsp;&amp;nbsp; add = [num,prefix,street,sttype,suffix,''.join(["#",unit.strip()])]
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = [''.join([a.strip()," "]) for a in add if a.strip() not in ['#None','','#']]
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = ''.join([f for f in fulladd]).strip()
&amp;nbsp;&amp;nbsp;&amp;nbsp; return fulladd
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:16:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85002#M6712</guid>
      <dc:creator>BruceBacia</dc:creator>
      <dc:date>2021-12-10T23:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85003#M6713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN style="font-size:2;"&gt;Ok, I promise this will be the last revision &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&amp;nbsp; I tend to obsess about these things sometimes.&amp;nbsp; Also, you might be able to change the little exclude list from ['#None','','#'] to ['','#']...... I'm not entirely sure of what a null value will return in this context (i.e. 'None' vs. '' vs. ' ').&amp;nbsp; You should mess around with it.&amp;nbsp; Cheers to working with structure data!&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&lt;SPAN style="font-size:1;"&gt;
def fulladd(num, prefix, street, sttype, suffix, unit):
&amp;nbsp;&amp;nbsp;&amp;nbsp; add = [num,prefix,street,sttype,suffix,''.join(["#",unit.strip()])]
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = ''.join([''.join([a.strip()," "]) for a in add if a.strip() not in ['#None','','#']]).strip()
&amp;nbsp;&amp;nbsp;&amp;nbsp; return fulladd
&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:16:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85003#M6713</guid>
      <dc:creator>BruceBacia</dc:creator>
      <dc:date>2021-12-10T23:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85004#M6714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;SPAN style="font-size:2;"&gt;Ok, I promise this will be the last revision &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&amp;nbsp; I tend to obsess about these things sometimes.&amp;nbsp; Also, you might be able to change the little exclude list from ['#None','','#'] to ['','#']...... I'm not entirely sure of what a null value will return in this context (i.e. 'None' vs. '' vs. ' ').&amp;nbsp; You should mess around with it.&amp;nbsp; Cheers to working with structure data!&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&lt;SPAN style="font-size:1;"&gt;
def fulladd(num, prefix, street, sttype, suffix, unit):
&amp;nbsp;&amp;nbsp;&amp;nbsp; add = [num,prefix,street,sttype,suffix,''.join(["#",unit.strip()])]
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = ''.join([''.join([a.strip()," "]) for a in add if a.strip() not in ['#None','','#']]).strip()
&amp;nbsp;&amp;nbsp;&amp;nbsp; return fulladd
&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That last one works perfectly on the ones I've tested so far.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, Bruce!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;**EDIT**&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Spoke too soon...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using a set of 4 records, I was testing this and it worked perfectly on records with or without Unit #s. But then I removed the values from UNIT for ones on which I'd already run the expression, and when I attempted to run the expression again, the calculation failed, with only a generic 999999 error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:16:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85004#M6714</guid>
      <dc:creator>CFrate</dc:creator>
      <dc:date>2021-12-10T23:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85005#M6715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There appears to be some issue related to running a calculation on a field more than once.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I ran the expression once, and it worked. I ran again without changing anything, and got the 999999 error again. Subsequent tests yield the same results.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2012 19:22:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85005#M6715</guid>
      <dc:creator>CFrate</dc:creator>
      <dc:date>2012-08-27T19:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85006#M6716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Carlo,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is probably null values.&amp;nbsp; Apparently you have to pass the field as a string (str(field)) to the function for field calculator to deal with these values.&amp;nbsp; Also, the field calculator window seems to always want to switch the little radio button at the top from "Python" to "VB", which will make it fail right off the bat.&amp;nbsp; This happened to me several times when testing. The solution below worked well with test structure data i used.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def fulladd(num,prefix,street,sttype,suffix,unit):
&amp;nbsp;&amp;nbsp;&amp;nbsp; add = [num,prefix,street,sttype,suffix,''.join(['#',unit])]
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = ''.join([''.join([a.strip()," "]) for a in add if a.strip() not in ['','#']]).strip()
&amp;nbsp;&amp;nbsp;&amp;nbsp; return fulladd
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 fulladdress(str(!AddNum!), str(!Prefix!) , str(!Street!) , str(!Type!) , str(!Suffix!) , str(!Unit!))
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:16:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85006#M6716</guid>
      <dc:creator>BruceBacia</dc:creator>
      <dc:date>2021-12-10T23:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85007#M6717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Heck, why not make it a one-liner&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&lt;SPAN style="font-size:1;"&gt;
def fulladd(num,prefix,street,sttype,suffix,unit):
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = ''.join([''.join([a.strip()," "]) for a in [num,prefix,street,sttype,suffix,''.join(['#',unit])]&amp;nbsp; if a.strip() not in ['','#']]).strip()
&amp;nbsp;&amp;nbsp;&amp;nbsp; return fulladd
&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 fulladdress(str(!AddNum!), str(!Prefix!) , str(!Street!) , str(!Type!) , str(!Suffix!) , str(!Unit!)).
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:16:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85007#M6717</guid>
      <dc:creator>BruceBacia</dc:creator>
      <dc:date>2021-12-10T23:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85008#M6718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Now I get this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"A field name was not found or there were unbalanced quotation marks"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The fields are all there and correct, and the syntax is checking out in Python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And, again, the expression works correctly at first, but after multiple tests on the same features it suddenly stops working. This latest attempt, the calculation ran correctly a few times, and then I tried to calculate another field and got the 999999 error. Then the expression would no longer function and would return 999999 and the above message.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm about to scrap this plan and just have this calculation run externally after scheduled post/reconcile tasks run.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 19:32:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85008#M6718</guid>
      <dc:creator>CFrate</dc:creator>
      <dc:date>2012-08-29T19:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation, concatenation</title>
      <link>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85009#M6719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That's strange, I haven't run into any issues like that. I ran it several times on the same dataset and it worked each time. Field calculator does seem pretty shady in 10. I added one fix below ---- will strip the unit value before joining it with "#" (will take care of any potential leading spaces on the unit value. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def fulladd(num,prefix,street,sttype,suffix,unit):
&amp;nbsp;&amp;nbsp;&amp;nbsp; fulladd = ''.join([''.join([a.strip()," "]) for a in [num,prefix,street,sttype,suffix,''.join(['#',unit.strip()])]&amp;nbsp; if a.strip() not in ['','#']]).strip()
&amp;nbsp;&amp;nbsp;&amp;nbsp; return fulladd
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:00:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculation-concatenation/m-p/85009#M6719</guid>
      <dc:creator>BruceBacia</dc:creator>
      <dc:date>2021-12-12T16:00:07Z</dc:date>
    </item>
  </channel>
</rss>

