<?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: Python Conditional Concatenation in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/python-conditional-concatenation/m-p/503522#M16758</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;True, I guess I didn't read the requirements very well:o&lt;BR /&gt;&lt;BR /&gt;Concatenation: A + B = AB.&lt;BR /&gt;Requirements description: If A or B then A or B, else nothing&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not sure how best to contact you directly, but I have been trying to modify a script you wrote and posted on the public scripts page about a year ago.&amp;nbsp; Your script permanently sorts a feature class or table to a new output feature class or table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have been trying to modify the script to optionally add a field to the output that will store a copy of the original data source's OID field values.&amp;nbsp; I need this where I want to join the output back to the source, but the data source has no other unique ID than the OID field and I cannot alter the source data schema to ensure that its OID values transfer to the output table created by your script.&amp;nbsp; Your script by default drops the original OID values from the output.&amp;nbsp; I have some code that basically works if I can assume that all OID fields are actually named "OBJECTID", but I do not think that is the case.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In VBA there are methods that can query a data source to confirm it has an OID and then get the OID field's name (which tells me there is more than one way these fields can be named).&amp;nbsp; Is there anything equivalent in Python?&amp;nbsp; Or how would you approach checking these two aspects of a data source to add appropriate error checking routines to your Python script to handle a subroutine like the one I want?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the script and I hope you can help me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Aug 2010 03:24:57 GMT</pubDate>
    <dc:creator>RichardFairhurst</dc:creator>
    <dc:date>2010-08-03T03:24:57Z</dc:date>
    <item>
      <title>Python Conditional Concatenation</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-conditional-concatenation/m-p/503518#M16754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;BACKGROUND:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-2 fields I wish to concatenate into one, on the condition that if BOTH fields have a value in them, only one is copied into the new concatenated field (either one, doesn't matter). If only one field has a value, that's the one that's transfered. If neither field has a value, the new concatenated field is blank.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-All fields are strings&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- ArcInfo, 9.3.1 SP2&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ISSUE:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Using VBA in the field calculator with IF and ELSE statements, I keep getting errors such as blank objectID, or the such. The other option would be python, for which I have no knowledge.&amp;nbsp; What would the python statement look like?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks, I've wasted 4 hours on this so far.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jul 2010 16:04:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-conditional-concatenation/m-p/503518#M16754</guid>
      <dc:creator>AndrewHunt</dc:creator>
      <dc:date>2010-07-27T16:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Python Conditional Concatenation</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-conditional-concatenation/m-p/503519#M16755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using an update cursor in Python, it would look something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcgisscripting&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp = arcgisscripting.create(9.3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inputFC = r"C:\temp\test.gdb\test"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fieldName1 = "THIS_FIELD"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fieldName2 = "THAT_FIELD"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;concatFieldName = "CONCAT_FIELD"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;updateRows = gp.updatecursor(inputFC)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;updateRow = updateRows.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while updateRow:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; if updateRow.getvalue(fieldName1) == None and updateRow.getvalue(fieldName2) != None:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow.setvalue(concatFieldName, updateRow.getvalue(fieldName2))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; elif updateRow.getvalue(fieldName1) != None and updateRow.getvalue(fieldName2) == None:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow.setvalue(concatFieldName, updateRow.getvalue(fieldName1))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; elif updateRow.getvalue(fieldName1) != None and updateRow.getvalue(fieldName2) != None:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow.setvalue(concatFieldName, str(updateRow.getvalue(fieldName1)) + "-" +&amp;nbsp; str(updateRow.getvalue(fieldName2)))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "FUBAR"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; updateRows.UpdateRow(updateRow)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; updateRow = updateRows.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del updateRow&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del updateRows&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jul 2010 20:13:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-conditional-concatenation/m-p/503519#M16755</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-07-27T20:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: Python Conditional Concatenation</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-conditional-concatenation/m-p/503520#M16756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using an update cursor in Python, it would look something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgisscripting
gp = arcgisscripting.create(9.3)
inputFC = r"C:\temp\test.gdb\test"
fieldName1 = "THIS_FIELD"
fieldName2 = "THAT_FIELD"
concatFieldName = "CONCAT_FIELD"
updateRows = gp.updatecursor(inputFC)
updateRow = updateRows.next()
while updateRow:
&amp;nbsp;&amp;nbsp; if updateRow.getvalue(fieldName1) == None and updateRow.getvalue(fieldName2) != None:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow.setvalue(concatFieldName, updateRow.getvalue(fieldName2))
&amp;nbsp;&amp;nbsp; elif updateRow.getvalue(fieldName1) != None and updateRow.getvalue(fieldName2) == None:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow.setvalue(concatFieldName, updateRow.getvalue(fieldName1))
&amp;nbsp;&amp;nbsp; elif updateRow.getvalue(fieldName1) != None and updateRow.getvalue(fieldName2) != None:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow.setvalue(concatFieldName, str(updateRow.getvalue(fieldName1)) + "-" +&amp;nbsp; str(updateRow.getvalue(fieldName2)))
&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "FUBAR"
&amp;nbsp;&amp;nbsp; updateRows.UpdateRow(updateRow)
&amp;nbsp;&amp;nbsp; updateRow = updateRows.next()
del updateRow
del updateRows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:05:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-conditional-concatenation/m-p/503520#M16756</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T22:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Python Conditional Concatenation</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-conditional-concatenation/m-p/503521#M16757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;True, I guess I didn't read the requirements very well:o&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Concatenation: A + B = AB.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Requirements description: If A or B then A or B, else nothing&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jul 2010 15:40:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-conditional-concatenation/m-p/503521#M16757</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-07-28T15:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: Python Conditional Concatenation</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-conditional-concatenation/m-p/503522#M16758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;True, I guess I didn't read the requirements very well:o&lt;BR /&gt;&lt;BR /&gt;Concatenation: A + B = AB.&lt;BR /&gt;Requirements description: If A or B then A or B, else nothing&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not sure how best to contact you directly, but I have been trying to modify a script you wrote and posted on the public scripts page about a year ago.&amp;nbsp; Your script permanently sorts a feature class or table to a new output feature class or table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have been trying to modify the script to optionally add a field to the output that will store a copy of the original data source's OID field values.&amp;nbsp; I need this where I want to join the output back to the source, but the data source has no other unique ID than the OID field and I cannot alter the source data schema to ensure that its OID values transfer to the output table created by your script.&amp;nbsp; Your script by default drops the original OID values from the output.&amp;nbsp; I have some code that basically works if I can assume that all OID fields are actually named "OBJECTID", but I do not think that is the case.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In VBA there are methods that can query a data source to confirm it has an OID and then get the OID field's name (which tells me there is more than one way these fields can be named).&amp;nbsp; Is there anything equivalent in Python?&amp;nbsp; Or how would you approach checking these two aspects of a data source to add appropriate error checking routines to your Python script to handle a subroutine like the one I want?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the script and I hope you can help me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Aug 2010 03:24:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-conditional-concatenation/m-p/503522#M16758</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2010-08-03T03:24:57Z</dc:date>
    </item>
  </channel>
</rss>

