<?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: arcpy.da.UpdateCursor to concatenate two strings in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708794#M54946</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It really shouldn't even be taking that long, unless your strings are really long or you are dealing with a slow computer. Did you try it in a file geodatabase?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Oct 2013 12:01:44 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2013-10-22T12:01:44Z</dc:date>
    <item>
      <title>arcpy.da.UpdateCursor to concatenate two strings</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708785#M54937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to figure out how to concatenate two strings using the arcpy.da.UpdateCursor method (newbie to python scripting).&amp;nbsp; I have tried many trial and error attempts in the basic code from resource center, and have yet to get one that will work.&amp;nbsp; Here is the code I am working with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; fc = " C:\Users\cc1\Desktop\Metro_Bus_Stops.shp" fields = ('City','TRIAL')&amp;nbsp;&amp;nbsp; with arcpy.da.UpdateCursor(fc, fields) as cursor:&amp;nbsp; in cursor: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[0] = row[1] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&amp;nbsp; &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code works fine for updating a new field with the current data form another field.&amp;nbsp; But I cannot get it to concatenate two fields together for the new third field.&amp;nbsp; Also, I have seen some literature with the ''.join() method, that I am interested in.&amp;nbsp; I am working with over 7 million records, and every once of performance I can gain is needed.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Oct 2013 16:57:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708785#M54937</guid>
      <dc:creator>ClintonCooper1</dc:creator>
      <dc:date>2013-10-21T16:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor to concatenate two strings</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708786#M54938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here's a quick example. Takes field0 and field1 and writes them to field2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;fields = ['field0', 'field1', 'field2'] cursor = arcpy.da.UpdateCursor(fc, fields) for row in cursor: &amp;nbsp;&amp;nbsp;&amp;nbsp; row[2] = '{0}{1}'.format(row[0], row[1]) &amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row) del cursor&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Oct 2013 17:08:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708786#M54938</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-10-21T17:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor to concatenate two strings</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708787#M54939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;do I change format to join?&amp;nbsp; Thank you for the quick reply!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Oct 2013 17:26:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708787#M54939</guid>
      <dc:creator>ClintonCooper1</dc:creator>
      <dc:date>2013-10-21T17:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor to concatenate two strings</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708788#M54940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That depends on what you want your output to be. What reason would you have for using join in this context?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Oct 2013 17:45:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708788#M54940</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-10-21T17:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor to concatenate two strings</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708789#M54941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to concatenate two fields, and the literature I have found says that .join is the solution to concatenate the two fields.&amp;nbsp; When I run the script you provided with my information, I am getting this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Runtime error &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 8, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IndexError: list assignment index out of range&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for this code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

import arcpy

fc = " C:\Users\cc1\Desktop\Metro_Bus_Stops.shp"

fields = ['City', 'County', 'TRIAL']
cursor = arcpy.da.UpdateCursor(fc, fields)
for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; row[3] = '{0}{1}'.format(row[0], row[1])
&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)
del cursor
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Clinton&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:46:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708789#M54941</guid>
      <dc:creator>ClintonCooper1</dc:creator>
      <dc:date>2021-12-12T05:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor to concatenate two strings</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708790#M54942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ah yes I mixed up the index for the 3rd field. Should be this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; row[&lt;STRONG&gt;2&lt;/STRONG&gt;] = '{0}{1}'.format(row[0], row[1])&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And what literature are you referring to?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:46:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708790#M54942</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-12T05:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor to concatenate two strings</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708791#M54943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It seems that the .join is an older method.&amp;nbsp; In your estimation, will this be the fastest method to concatenate strings (aka faster than field calculator)?&amp;nbsp;&amp;nbsp; Or is&amp;nbsp; there another method that will be much faster?&amp;nbsp; As I have said in previous posts, I need to do this calc on 7+ million records...through field calculator this takes 24 hours....&amp;nbsp; Thanks again for all your help!!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Oct 2013 18:53:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708791#M54943</guid>
      <dc:creator>ClintonCooper1</dc:creator>
      <dc:date>2013-10-21T18:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor to concatenate two strings</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708792#M54944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Assuming I/O isn't your issue this method should take less than 2 minutes for 7 million records (takes around 10 seconds for 500k records for me). The only faster way I can think of is it do this through SQL directly in a database.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Oct 2013 21:06:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708792#M54944</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-10-21T21:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor to concatenate two strings</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708793#M54945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ran through it last night, and it took around 10 to 15 minutes for a shapefile.&amp;nbsp; I then ran it again on a table (hoping to skip the geocoding process), and it took around 30 to 45 minutes.&amp;nbsp; Can't complain as this is about 10 to 20 times faster than field calculator.&amp;nbsp; I may eventually look into doing it through sql, but for now this will suffice!&amp;nbsp; Thanks again!!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Oct 2013 11:18:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708793#M54945</guid>
      <dc:creator>ClintonCooper1</dc:creator>
      <dc:date>2013-10-22T11:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor to concatenate two strings</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708794#M54946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It really shouldn't even be taking that long, unless your strings are really long or you are dealing with a slow computer. Did you try it in a file geodatabase?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Oct 2013 12:01:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708794#M54946</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-10-22T12:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor to concatenate two strings</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708795#M54947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;nope, just in an sde.&amp;nbsp; I am combining three strings at around 50 to 75 characters.&amp;nbsp; I have set the field length to 100 characters.&amp;nbsp; I have a top of the line comp with 16 gb of ram and a 3.8 gb processor (with 10 mb cache).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Oct 2013 12:30:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-to-concatenate-two-strings/m-p/708795#M54947</guid>
      <dc:creator>ClintonCooper1</dc:creator>
      <dc:date>2013-10-22T12:30:47Z</dc:date>
    </item>
  </channel>
</rss>

