<?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 and Paste specific row in the same point fc for several fclasses in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/copy-and-paste-specific-row-in-the-same-point-fc/m-p/76262#M6192</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you explain why you are trying to do what you are trying to do?&amp;nbsp; Before diving into technical specifics, I think there are some logical issues that need to be sorted out first.&amp;nbsp; For example, what does inserting a new record at the "top" of the table get you?&amp;nbsp; For that matter, what do you mean by "top" of a table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In SQL, the ordering of data isn't guaranteed unless you specify an ORDER BY clause.&amp;nbsp; Without using an ORDER BY clause, there are no guarantees that data will be retrieved in a certain, or even consistent, manner.&amp;nbsp; ArcGIS Desktop seems to present rows to the user ordered by ObjectID or FID, but I don't know if that is guaranteed.&amp;nbsp; Even if it is, it is an Esri-ism and not standard with SQL or DMBSes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking at technical issues, what specifically are your error messages?&amp;nbsp; Specific error messages are helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding insert and update cursors, you can't manipulate the built-in unique identifier field, it is managed by the system.&amp;nbsp; Just think of the mayhem that could ensue if users could arbitrarily update a system generated and managed field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Mar 2015 21:24:51 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2015-03-30T21:24:51Z</dc:date>
    <item>
      <title>Copy and Paste specific row in the same point fc for several fclasses</title>
      <link>https://community.esri.com/t5/python-questions/copy-and-paste-specific-row-in-the-same-point-fc/m-p/76261#M6191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have 10 point feature classes to process each of them having different name, in which i must copy and paste a specific row, updating also a specific column with new values, doing that with a loop for 10 pnts . Maybe it's easy to many of you, but as new to programming i can't understand very well how to use ArcPy for my procedure. I have written this script for the things i want to do with my point fc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. copy the last row which is different for each fc&lt;/P&gt;&lt;P&gt;2. paste it in the first row without overwritting the existing feature there&lt;/P&gt;&lt;P&gt;3. delete the last row i used for copy &lt;/P&gt;&lt;P&gt;4. update the FID column starting from 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my tables are in the form of:&lt;/P&gt;&lt;P&gt;FID&amp;nbsp;&amp;nbsp;&amp;nbsp; SHAPE&amp;nbsp;&amp;nbsp; LINEOID&amp;nbsp;&amp;nbsp;&amp;nbsp; VALIE&lt;/P&gt;&lt;P&gt;0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; POINT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; POINT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; POINT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; POINT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 40&lt;/P&gt;&lt;P&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; POINT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 50&lt;/P&gt;&lt;P&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; POINT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 60&lt;/P&gt;&lt;P&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; POINT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 70&lt;/P&gt;&lt;P&gt;7..&lt;/P&gt;&lt;P&gt;8..&lt;/P&gt;&lt;P&gt;500&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; POINT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If someone can answer, PLEASE it will help if responding a bit analytically about the mistakes in my script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# PURPOSE:CALCULATE THE NUMBER OF FEATURES IN A FEATURE CLASS,&amp;nbsp; Name: fcCount.py&lt;/P&gt;&lt;P&gt;# Import system modules&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;lyrfile = "c:/W/S/pntp.lyr"&lt;/P&gt;&lt;P&gt;result = arcpy.GetCount_management(lyrfile)&lt;/P&gt;&lt;P&gt;count = int(result.getOutput(0))&lt;/P&gt;&lt;P&gt;print count&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;#SELECT ANALYSIS-EXPORT SELECTED ROW/FEATURE AS PNTP2&lt;/P&gt;&lt;P&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;arcpy.Select_analysis("pntp.shp", "C:/W/S/pntp2.shp", 'FID = count')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#DELETE ROW WITH UPDATE CURSOR&lt;/P&gt;&lt;P&gt;with arcpy.da.UpdateCursor("c:/W/S/pntp.shp",["FID"]) as cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = max([FID])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print C&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row[0] ==(count):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.deleteRow()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#INSERT CURSOR&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;# Create an insert cursor for a table specifying the fields that will have values provided&lt;/P&gt;&lt;P&gt;fields = ['FID', 'Shape', 'LineOID', 'Valie']&lt;/P&gt;&lt;P&gt;cursor = arcpy.da.InsertCursor('c:/W/S/pntp.shp', fields)&lt;/P&gt;&lt;P&gt;# Create 1 new row at top of the attribute table TO INSERT the feature PNTP2&lt;/P&gt;&lt;P&gt;for x in(0):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.insertRow((0, 0, 0, 0))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete cursor object&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; del cursor&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#UPDATE CURSOR&lt;/P&gt;&lt;P&gt;with arcpy.da.UpdateCursor("c:/W/S/pntp.shp",["FID"]) as cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FID += 1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Mar 2015 20:42:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-and-paste-specific-row-in-the-same-point-fc/m-p/76261#M6191</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2015-03-30T20:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Copy and Paste specific row in the same point fc for several fclasses</title>
      <link>https://community.esri.com/t5/python-questions/copy-and-paste-specific-row-in-the-same-point-fc/m-p/76262#M6192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you explain why you are trying to do what you are trying to do?&amp;nbsp; Before diving into technical specifics, I think there are some logical issues that need to be sorted out first.&amp;nbsp; For example, what does inserting a new record at the "top" of the table get you?&amp;nbsp; For that matter, what do you mean by "top" of a table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In SQL, the ordering of data isn't guaranteed unless you specify an ORDER BY clause.&amp;nbsp; Without using an ORDER BY clause, there are no guarantees that data will be retrieved in a certain, or even consistent, manner.&amp;nbsp; ArcGIS Desktop seems to present rows to the user ordered by ObjectID or FID, but I don't know if that is guaranteed.&amp;nbsp; Even if it is, it is an Esri-ism and not standard with SQL or DMBSes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking at technical issues, what specifically are your error messages?&amp;nbsp; Specific error messages are helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding insert and update cursors, you can't manipulate the built-in unique identifier field, it is managed by the system.&amp;nbsp; Just think of the mayhem that could ensue if users could arbitrarily update a system generated and managed field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Mar 2015 21:24:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-and-paste-specific-row-in-the-same-point-fc/m-p/76262#M6192</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-03-30T21:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Copy and Paste specific row in the same point fc for several fclasses</title>
      <link>https://community.esri.com/t5/python-questions/copy-and-paste-specific-row-in-the-same-point-fc/m-p/76263#M6193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need the inserted row to be the first row (at the top of the rows) for further procession, afterwards.&lt;/P&gt;&lt;P&gt;So The ORDER BY clause maube be useless?&lt;/P&gt;&lt;P&gt;For the last thing you wrote abour the cursors, would be better if i create a new field with the values i want?&lt;/P&gt;&lt;P&gt;Delete the post?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Mar 2015 21:54:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-and-paste-specific-row-in-the-same-point-fc/m-p/76263#M6193</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2015-03-30T21:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Copy and Paste specific row in the same point fc for several fclasses</title>
      <link>https://community.esri.com/t5/python-questions/copy-and-paste-specific-row-in-the-same-point-fc/m-p/76264#M6194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you need records processed in a certain order, don't use the system-generated and system-managed unique identifier field.&amp;nbsp; For one, the insert and update cursors don't allow users to directly manage/change those fields so you aren't going to be able to do what you want to do with those field.&amp;nbsp; Second, an insert cursor is more like appending to a list than inserting in a list because it doesn't allow you to specify where in the table the record will be inserted.&amp;nbsp; Which leads me to my third point, you are going to have to use an ORDER BY clause on your cursors with your newly created order-processing field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Mar 2015 22:26:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-and-paste-specific-row-in-the-same-point-fc/m-p/76264#M6194</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-03-30T22:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Copy and Paste specific row in the same point fc for several fclasses</title>
      <link>https://community.esri.com/t5/python-questions/copy-and-paste-specific-row-in-the-same-point-fc/m-p/76265#M6195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok i got it. The problem i have with ORDER BY in attribute table is that it understands the field Valie as strings and not as integers or numbers. As a result when i am trying it, i am getting&lt;/P&gt;&lt;P&gt;0&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;100&lt;/P&gt;&lt;P&gt;1000&lt;/P&gt;&lt;P&gt;1010&lt;/P&gt;&lt;P&gt;1020&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;1090&lt;/P&gt;&lt;P&gt;110&lt;/P&gt;&lt;P&gt;1100&lt;/P&gt;&lt;P&gt;1120&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why is that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Mar 2015 22:36:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-and-paste-specific-row-in-the-same-point-fc/m-p/76265#M6195</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2015-03-30T22:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: Copy and Paste specific row in the same point fc for several fclasses</title>
      <link>https://community.esri.com/t5/python-questions/copy-and-paste-specific-row-in-the-same-point-fc/m-p/76266#M6196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The cursor is treating Valie as a string because it is just that, a string.&amp;nbsp; Overall, and especially since it looks like you are storing numbers as text, I encourage you to convert Valie from a string field to some form of numeric field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Normally I would suggest using a CAST function within your ORDER BY clause, but I have never had success getting that to work with the sql_clause of ArcPy cursors.&amp;nbsp; From my read of the documentation, I am unclear whether it is supported only in subqueries for certain data formats or whether it is more generally supported.&amp;nbsp; If you find out or get it working, please share.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One final option that I know works with search cursors, but I don't know how it would behave with update cursors, is to use Python's built-in sorting methods.&amp;nbsp; Also, this could be a big performance bust on larger data sets.&amp;nbsp; In effect, you presort the cursor just before iterating over it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;cur = arcpy.da.SearchCursor(in_table, field_names)
i = #index of Valie field
for row &lt;SPAN style="color: #004da8;"&gt;in&lt;/SPAN&gt; sorted(cur, key=&lt;SPAN style="color: #004da8;"&gt;lambda&lt;/SPAN&gt; f: int(f&lt;I&gt;)):&lt;/I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; print row&lt;I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Overall, your life will be much much simpler if you can convert Valie to a numeric field or create a new field that is numeric to base your sorting/ordering upon.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:57:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-and-paste-specific-row-in-the-same-point-fc/m-p/76266#M6196</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-10T22:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: Copy and Paste specific row in the same point fc for several fclasses</title>
      <link>https://community.esri.com/t5/python-questions/copy-and-paste-specific-row-in-the-same-point-fc/m-p/76267#M6197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;and of course you were right, i must sleep more maybe and also think fisrt the simple way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Apr 2015 07:37:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-and-paste-specific-row-in-the-same-point-fc/m-p/76267#M6197</guid>
      <dc:creator>KONPETROV</dc:creator>
      <dc:date>2015-04-01T07:37:29Z</dc:date>
    </item>
  </channel>
</rss>

