<?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: Concatenate Multi-Values from Single Field and Insert to Single Cell in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021497#M59686</link>
    <description>&lt;P&gt;Your current process is passing a featureclass with a selected feature to the script.&amp;nbsp; using the selected feature as input, you can use a search cursor to access the features data.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;inTable = input from your model, which will be Table1
destTable = input from your model, which will be Table2

with arcpy.da.SearchCursor(inTable , Field_A) as cur:
    for row in cur:
        resString = 'Value 1: {} Value 2: {}'.format(row[0].split(' ')[0], row[0].split(' ')[1])
        # insert into target FC
        arcpy.da.InsertCursor(Table2, Field_B) as cur:
             cur.insertRow(resString)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will need to set this script up as a script tool, then drag and drop that tool it into your model and wire up the input parameters.&lt;/P&gt;</description>
    <pubDate>Fri, 29 Jan 2021 14:05:12 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-01-29T14:05:12Z</dc:date>
    <item>
      <title>Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021317#M59683</link>
      <description>&lt;P&gt;I'm building a geoprocessing model that iterates through features in one f-class and spatially selects features from another f-class that are within a certain distance of each feature.&amp;nbsp; I want to pull values from one f-class to the other.&amp;nbsp; The model essentially does a select features by location, and from that selection I would like to pull values within a single field, concatenate them together as a string and insert that value into the other f-class field in a single cell. I believe that I need to use some cursors within ArcPy to do this (SearchCursor &amp;amp; InsertCursor) and embed the Python script within the model, but I'm not entirely sure. So basically Table1 FIELD_A has two values "1234" and "5678". I want to take those two values and insert them into a single cell within Table2 FIELD_B so that the value looks something like "Value 1: 1234 to Value 2: 5678". Any assistance would be appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 22:28:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021317#M59683</guid>
      <dc:creator>EricMahaffey1</dc:creator>
      <dc:date>2021-01-28T22:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021346#M59684</link>
      <description>&lt;P&gt;Maybe you can clarify what the objective is as well as you data structure.&amp;nbsp; Are you randomly inserting the values from Table1 into Table2 or is there some sort of correlation between the two?&amp;nbsp; Does Table2 already exist (update cursor) or are you truly inserting new records (insert cursor).&lt;/P&gt;&lt;P&gt;You mention that Table1 FieldA has two values " 1234" and "5678" ; if both of those strings of characters are within a single field, that field has one value: "1234 5678".&amp;nbsp; &amp;nbsp;A few more details would really help to provide a solution.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 23:23:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021346#M59684</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-01-28T23:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021497#M59686</link>
      <description>&lt;P&gt;Your current process is passing a featureclass with a selected feature to the script.&amp;nbsp; using the selected feature as input, you can use a search cursor to access the features data.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;inTable = input from your model, which will be Table1
destTable = input from your model, which will be Table2

with arcpy.da.SearchCursor(inTable , Field_A) as cur:
    for row in cur:
        resString = 'Value 1: {} Value 2: {}'.format(row[0].split(' ')[0], row[0].split(' ')[1])
        # insert into target FC
        arcpy.da.InsertCursor(Table2, Field_B) as cur:
             cur.insertRow(resString)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will need to set this script up as a script tool, then drag and drop that tool it into your model and wire up the input parameters.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 14:05:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021497#M59686</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-01-29T14:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021632#M59690</link>
      <description>&lt;P&gt;Thanks for the quick reply Jeff.&amp;nbsp; I'll give this a shot and let you know how it turns out.&amp;nbsp; Appreciate the help!&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 17:46:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021632#M59690</guid>
      <dc:creator>EricMahaffey1</dc:creator>
      <dc:date>2021-01-29T17:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021709#M59692</link>
      <description>&lt;P&gt;HI Joe.&amp;nbsp; The values that I'm trying to take from Table1 are the results of a spatial query.&amp;nbsp; In this case two separate values ("1234" and "5678") from two cells in the same field of the selected features.&amp;nbsp; I'm trying to insert both of those values into a single cell within Table2 ("Value 1: 1234 to Value 2: 5678").&amp;nbsp; Table2 already exists and the target field is there.&amp;nbsp; I hope this answers your questions.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 20:00:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021709#M59692</guid>
      <dc:creator>EricMahaffey1</dc:creator>
      <dc:date>2021-01-29T20:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021716#M59693</link>
      <description>&lt;P&gt;Okay; I think it's a nomenclature issue for me.&amp;nbsp; You have &lt;EM&gt;two records&lt;/EM&gt; in Table1, and the respective values in the Field need to be returned to one field in Table2.&amp;nbsp; I'm not much of a model builder, but in a straight python script I can see how you would do that.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 20:11:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021716#M59693</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-01-29T20:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021726#M59694</link>
      <description>&lt;P&gt;Jeff,&lt;/P&gt;&lt;P&gt;I setup two stand alone f-classes to emulate the selection results from within the model. I figured if I can get the script to function with those, then I can focus on embedding it within the model next. When I first started running the code I was getting an invalid syntax error within&lt;/P&gt;&lt;P&gt;arcpy.da.InsertCursor(Table2, Field_B) as cur:&lt;/P&gt;&lt;P&gt;I moved things around to appear like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EricMahaffey1_1-1611951722545.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/4938iE24361DF02F3D9CB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="EricMahaffey1_1-1611951722545.png" alt="EricMahaffey1_1-1611951722545.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;, but now I'm getting a "IndexError: list index out of range" error. Any ideas?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 20:22:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021726#M59694</guid>
      <dc:creator>EricMahaffey1</dc:creator>
      <dc:date>2021-01-29T20:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021743#M59696</link>
      <description>&lt;P&gt;Insert cursor uses a tuple of values for the insertRow so you will need to wrap that resString string with (), I often forget that aspect of insertcursor's and I see that I missed it in the previous example.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at your image, printing the cursor will just print the object so its not really doing anything.&amp;nbsp; Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;      print row[0]  #should be the '1234 5678'?
      resString = 'Value 1: {} Value 2: {}'.format(row[0].split(' ')[0], row[0].split(' ')[1])
      print resString
      insertcursor.insertRow((resString))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this doesn't work, share the print results with us so we get an idea of the data value/format.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 20:56:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021743#M59696</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-01-29T20:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021748#M59697</link>
      <description>&lt;P&gt;Thanks Jeff.&amp;nbsp; I changed the code per your last suggestion.&amp;nbsp; I'm still getting the "list index out of range".&amp;nbsp; The print results only show one value, but I think it should show two.&amp;nbsp; Which from I remember might be causing the index to be out of range in "reString"&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EricMahaffey1_0-1611954208680.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/4939i214EE6E19A9BDA19/image-size/medium?v=v2&amp;amp;px=400" role="button" title="EricMahaffey1_0-1611954208680.png" alt="EricMahaffey1_0-1611954208680.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 21:05:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021748#M59697</guid>
      <dc:creator>EricMahaffey1</dc:creator>
      <dc:date>2021-01-29T21:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021759#M59698</link>
      <description>&lt;P&gt;It would have failed on the insertRow eventually...&amp;nbsp; It failing on the reString tells me that the data in 'MILE_TEXT' field is not "1234 5678" and it is not splitting into two ('1234', '5678').&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the image, it printed 337.&amp;nbsp; Do you have the right cell for the cursor, or are there mixed values like 337 and 333 789?&amp;nbsp; If it is mixed like that, you will need a conditional to skip the split if there is only one.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if ' ' in row[0]:
   resString = split code
else:
   resString = 'Value 1: {}'.format(row[0])

insertCursor.insertRow((resString))&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 29 Jan 2021 21:27:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021759#M59698</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-01-29T21:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021764#M59699</link>
      <description>&lt;P&gt;Correct.&amp;nbsp; The data in the MILE_TEXT field would be 337 in the first cell, then 336 in the second cell.&amp;nbsp; I'd like to grab these two values then insert them into a single cell within the MILE_MARKERS field within the River_Section table.&amp;nbsp; So in theory I think there's no need for the split at all now that I look at it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 21:34:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021764#M59699</guid>
      <dc:creator>EricMahaffey1</dc:creator>
      <dc:date>2021-01-29T21:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021773#M59700</link>
      <description>&lt;P&gt;ok, still a little muddy on how your data is structured.&amp;nbsp; If your table looks like:&lt;/P&gt;&lt;P&gt;id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Mile_text&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 337&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 338&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 339&lt;/P&gt;&lt;P&gt;you'll need to store the previous value into a variable and recall it on the current&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;inTable = input from your model, which will be Table1
destTable = input from your model, which will be Table2
miletext = ''

with arcpy.da.SearchCursor(inTable , Field_A) as cur:
    for row in cur:
        if miletext != '':
            resString = 'Value 1: {} Value 2: {}'.format(miletext, row[0])
        else: # for the first value before miletext gets assigned
            resString = 'Value 1: {}'.format(row[0])
        # insert into target FC
        with arcpy.da.InsertCursor(Table2, Field_B) as incur:
             incur.insertRow((resString))
        # set new value to miletext for next concat
        miletext = row[0]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 22:26:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021773#M59700</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-01-29T22:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021784#M59701</link>
      <description>&lt;P&gt;Sorry for that I'm not able to explain this very clearly Jeff.&amp;nbsp; You're correct with how the table is structured.&amp;nbsp; When I run the last code sample, I'm back to the syntax error with the second "as" in the script.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EricMahaffey1_0-1611958347918.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/4943i87D3DC84558EC297/image-size/medium?v=v2&amp;amp;px=400" role="button" title="EricMahaffey1_0-1611958347918.png" alt="EricMahaffey1_0-1611958347918.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 22:13:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021784#M59701</guid>
      <dc:creator>EricMahaffey1</dc:creator>
      <dc:date>2021-01-29T22:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021786#M59702</link>
      <description>&lt;P&gt;I think you need Mile_markers in quote and give it a different name than the searchcursor.&amp;nbsp; The way you had it would be ok too.&amp;nbsp; Sorry I just grabbed that code from an earlier post.&lt;/P&gt;&lt;P&gt;I just remembered that you are passing the selected feature to this tool so it will only be one row instead of a table of rows.&amp;nbsp; You'll have to change that part of model so the selection will be part of this script if you want to the previous value to be persisted for the next iteration.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 22:18:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021786#M59702</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-01-29T22:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021787#M59703</link>
      <description>&lt;P&gt;Shouldn't the line with the InsertCursor start with "with"?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 22:19:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021787#M59703</guid>
      <dc:creator>JamesWilcox1970</dc:creator>
      <dc:date>2021-01-29T22:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021788#M59704</link>
      <description>&lt;P&gt;yes, yes it should.&amp;nbsp; Fixed (along with the cursor name) Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 22:21:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021788#M59704</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-01-29T22:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021789#M59705</link>
      <description>&lt;P&gt;Yeah I noticed the need for quotes around the field name right before you responded.&amp;nbsp; After inserting them, I now get a TypeError: sequence size must match size of the row when I run it.&amp;nbsp; The field width that I'm inserting to is plenty large so I'm not sure what's causing it.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 22:28:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021789#M59705</guid>
      <dc:creator>EricMahaffey1</dc:creator>
      <dc:date>2021-01-29T22:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021791#M59706</link>
      <description>&lt;P&gt;Check if you have double parenthesis : insertRow((resString)).&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 22:30:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021791#M59706</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-01-29T22:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021797#M59707</link>
      <description>&lt;P&gt;Thanks guys.&amp;nbsp; That seemed to work.&amp;nbsp; No errors now, and I'm getting data in the second table.&amp;nbsp; However, it's producing two rows.&amp;nbsp; The first row only has one value, the second looks correct with both values&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EricMahaffey1_0-1611960135377.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/4944iB8ED88791DC76086/image-size/medium?v=v2&amp;amp;px=400" role="button" title="EricMahaffey1_0-1611960135377.png" alt="EricMahaffey1_0-1611960135377.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I also had to use brackets instead of parenthesis around reString&lt;/P&gt;&lt;P&gt;with arcpy.da.InsertCursor(River_Section, "MILE_MARKERS") as iCursor:&lt;BR /&gt;iCursor.insertRow([resString])&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 22:44:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021797#M59707</guid>
      <dc:creator>EricMahaffey1</dc:creator>
      <dc:date>2021-01-29T22:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Multi-Values from Single Field and Insert to Single Cell</title>
      <link>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021862#M59709</link>
      <description>&lt;P&gt;I think we can sum this up a little, now that we figured out the data structure and worked through the cursors.&lt;/P&gt;&lt;P&gt;This script will accept the selection you pass into it, and uses another cursor to get the previous mile_text by filtering the selections Adjacent_MileMarkers row ID -1.&amp;nbsp; This relies on the previous value needed being the previous row Id in the table and not your previous selections mile_text.&lt;/P&gt;&lt;P&gt;If your selection's Id is 1 (or your lowest), there will not be any previous value to get so that selection should default to inserting just Value 1.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.SearchCursor(Adjecent_MileMarkers, ['OBJECTID', 'MILE_TEXT']) as cur:
    for row in cur:
        # Use your lowest ID here because that will be your floor
        if row[0] != 1:
            # Create your filter to get the previous value using the current Id - 1
            wc = """OBJECTID = {}""".format(row[0] - 1)
            # get the previous Mile_Text value by filtering the for Id -1
            previousMT = [x[1] for x in arcpy.da.SearchCursor(Adjecent_MileMarkers, ['OBJECTID', 'MILE_TEXT'], wc)][0]
            resString = 'Value 1: {} Value 2: {}'.format(previousMT, row[1])
            print(resString)
        else:
            # if the incoming selection is your floor, there will not be any previous 'MILE_TEXT'.
            resString = 'Value 1: {}'.format(row[1])
        # insert into target FC
        with arcpy.da.InsertCursor(River_Section, 'MILE_MARKERS') as incur:
             incur.insertRow([resString])&lt;/LI-CODE&gt;&lt;P&gt;will output:&lt;/P&gt;&lt;P&gt;Value 1: 658 Value 2: 659&lt;BR /&gt;Value 1: 670 Value 2: 671&lt;BR /&gt;Value 1: 652 Value 2: 653&lt;BR /&gt;Value 1: 666 Value 2: 667&lt;/P&gt;&lt;P&gt;If its not that sequential and you need the previous selections mile_text value, you'll have to include your feature selections in the script in order to maintain the previous mile_text. for example:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;miletext = ''

# insert your selection iteration here
for f in ['iteratable list or something']:
    selFeature = arcpy.SelectLayerByLocation_management('selection stuff based on other stuff and f from the iterator')
    with arcpy.da.SearchCursor(selFeature, 'MILE_TEXT') as cur:
        for row in cur:
            if miletext != '':
                resString = 'Value 1: {} Value 2: {}'.format(miletext, row[0])
                print(resString)
            else:
                resString = 'Value 1: {}'.format(row[0])
            # insert into target FC
            with arcpy.da.InsertCursor(River_Section, 'MILE_MARKERS') as incur:
                 incur.insertRow([resString])
            miletext = row[0]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jan 2021 13:45:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/concatenate-multi-values-from-single-field-and/m-p/1021862#M59709</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-01-30T13:45:02Z</dc:date>
    </item>
  </channel>
</rss>

