<?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: Copy/duplicate rows with arcpy in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/copy-duplicate-rows-with-arcpy/m-p/1351781#M75398</link>
    <description>&lt;P&gt;You want an Insert Cursor, not an update cursor. Update is for editing rows that are already in the table, insert is for adding new ones.&lt;/P&gt;&lt;P&gt;I wrote this without testing, but the basic workflow is:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Read the table and load the row (a tuple with only 1 value) into a list of tuples.&lt;/LI&gt;&lt;LI&gt;With the insert cursor, count the number of commas in the first value of each row in the list.&lt;/LI&gt;&lt;LI&gt;If the number is greater than 1, insert the row X many times.&lt;OL&gt;&lt;LI&gt;I really am not sure of the math here, so you'll have to play around a bit to make sure it's right.&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Also, am not sure if you're putting the rows into the same feature class or a new one, but either way you want an insert cursor.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;rowList = []
with arcpy.da.SearchCursor(input_fc, 'plots') as sCur:
    for row in sCur:
        rowList.append(row)


with arcpy.da.InsertCursor('input_fc','plots') as iCur:
    for row in rowList:
        number = row[0].count(',')
        if  number &amp;gt; 1:
            for i in range(1, number):
                iCur.insertRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also recommend asking python question in the&amp;nbsp;&lt;A href="https://community.esri.com/t5/python-questions/bd-p/python-questions" target="_self"&gt;Python Questions board&lt;/A&gt; for faster responses.&lt;/P&gt;</description>
    <pubDate>Tue, 21 Nov 2023 01:28:21 GMT</pubDate>
    <dc:creator>AlfredBaldenweck</dc:creator>
    <dc:date>2023-11-21T01:28:21Z</dc:date>
    <item>
      <title>Copy/duplicate rows with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/copy-duplicate-rows-with-arcpy/m-p/1351493#M75365</link>
      <description>&lt;P&gt;I have a table (no spatial data) of cadastral data indicating monuments, where several plots have been combined into one single row. I want to disentangle them to join them with the base cadastral set. I would rather not do this manually. I have been trying to figure out a way to make duplicate rows with arcpy based on the number of "," in one field. This is how far I got:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;with arcpy.da.UpdateCursor('input_fc','plots') as uCur:
    for row in uCur:
        list = []
        if ',' in row[0]:
            number = row[0].count(',')
            r = range(1,number,1)
            for i in r:&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;and that is where I got stuck trying to figure out how to tell it to duplicate the row as many times as there is a comma. Does anything like that exist?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 15:32:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/copy-duplicate-rows-with-arcpy/m-p/1351493#M75365</guid>
      <dc:creator>IlkaIllers1</dc:creator>
      <dc:date>2023-11-20T15:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Copy/duplicate rows with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/copy-duplicate-rows-with-arcpy/m-p/1351781#M75398</link>
      <description>&lt;P&gt;You want an Insert Cursor, not an update cursor. Update is for editing rows that are already in the table, insert is for adding new ones.&lt;/P&gt;&lt;P&gt;I wrote this without testing, but the basic workflow is:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Read the table and load the row (a tuple with only 1 value) into a list of tuples.&lt;/LI&gt;&lt;LI&gt;With the insert cursor, count the number of commas in the first value of each row in the list.&lt;/LI&gt;&lt;LI&gt;If the number is greater than 1, insert the row X many times.&lt;OL&gt;&lt;LI&gt;I really am not sure of the math here, so you'll have to play around a bit to make sure it's right.&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Also, am not sure if you're putting the rows into the same feature class or a new one, but either way you want an insert cursor.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;rowList = []
with arcpy.da.SearchCursor(input_fc, 'plots') as sCur:
    for row in sCur:
        rowList.append(row)


with arcpy.da.InsertCursor('input_fc','plots') as iCur:
    for row in rowList:
        number = row[0].count(',')
        if  number &amp;gt; 1:
            for i in range(1, number):
                iCur.insertRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also recommend asking python question in the&amp;nbsp;&lt;A href="https://community.esri.com/t5/python-questions/bd-p/python-questions" target="_self"&gt;Python Questions board&lt;/A&gt; for faster responses.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 01:28:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/copy-duplicate-rows-with-arcpy/m-p/1351781#M75398</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-11-21T01:28:21Z</dc:date>
    </item>
  </channel>
</rss>

