<?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: How to indentify duplicate or unique value in Pro RuntimeError: Error 999999 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1029754#M60065</link>
    <description>&lt;P&gt;For unique, duplicates etc, numpy is the way to go.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
from arcpy.da import TableToNumPyArray, NumPyArrayToTable
f = r"C:\arcpro_npg\npg\Project_npg\npgeom.gdb\sample_10k"  # --- a 10k -ish table
arr = TableToNumPyArray(f, "*")  # --- produce the array
flds = arr.dtype.names  # ---- to get all the fields
sub = arr[['County', 'Town_class', 'Facility']]  # --- subsample of the  fields
uni, idx, cnts = np.unique(sub, True, return_counts=True)  # --- perform unique

uni # ---- unique records for those 3 fields
array([('A', 'A_', 'Hall'), ('A', 'A_', 'Hosp'), ('A', 'B_', 'Hall'),
       ('A', 'B_', 'Hosp'), ('A', 'C_', 'Hall'), ('A', 'C_', 'Hosp'),
       ('B', 'A_', 'Hall'), ('B', 'A_', 'Hosp'), ('B', 'B_', 'Hall'),
       ('B', 'B_', 'Hosp'), ('B', 'C_', 'Hall'), ('B', 'C_', 'Hosp'),
       ('C', 'A_', 'Hall'), ('C', 'A_', 'Hosp'), ('C', 'B_', 'Hall'),
       ('C', 'B_', 'Hosp'), ('C', 'C_', 'Hall'), ('C', 'C_', 'Hosp'),
       ('D', 'A_', 'Hall'), ('D', 'A_', 'Hosp'), ('D', 'B_', 'Hall'),
       ('D', 'B_', 'Hosp'), ('D', 'C_', 'Hall'), ('D', 'C_', 'Hosp')],
      dtype={'names':['County','Town_class','Facility'], 'formats': 
                     ['&amp;lt;U4','&amp;lt;U12','&amp;lt;U16'], 'offsets':[8,24,72],
                      'itemsize':2184})

cnts # ---- counts for each unique record
array([590, 605, 465, 448, 442, 481, 554, 583, 446, 426, 491, 469, 607,
       621, 433, 468, 448, 457, 183, 198, 121, 162, 158, 140], dtype=int64)

sum(cnts)
9996

# ----
# NumPyArrayToTable  =====&amp;gt;  and back to Arc-world&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 23 Feb 2021 21:04:18 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2021-02-23T21:04:18Z</dc:date>
    <item>
      <title>How to indentify duplicate or unique value in Pro RuntimeError: Error 999999</title>
      <link>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1029623#M60059</link>
      <description>&lt;P&gt;I'm using the &lt;A href="https://support.esri.com/en/technical-article/000023355" target="_self"&gt;How to identify duplicate or unique values in Pro&lt;/A&gt; code provided by ERSI&amp;nbsp; verbatim, and I'm getting an error. I have a feature class table that I'm looking for duplicates in. The technical document doesn't say whether to use the field name or alias, so I tried both. When I run it with the field name the code throws an exception. I stopped the script and opened Pro. The field gets created in the table but it's all NULLs.&lt;/P&gt;&lt;P&gt;This is the line where the exception is being thrown:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;i=row.getValue(field_in)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Exception/Error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;  Message=ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
  Source=\\GISFILE\GISSTAFF\Jared\Python Scripts\ArcGISPro\DuplicateFields.py
  StackTrace:
  File "\\GISFILE\GISSTAFF\Jared\Python Scripts\ArcGISPro\DuplicateFields.py", line 17, in &amp;lt;module&amp;gt;
    i=row.getValue(field_in)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run it with the alias it doesn't finish, or at least I've never let it because it's taking a remarkably long time. However, if I stop the script and open Pro to view the table, a lot of the 190K+ fields are written to. But, like I said it never finishes...&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;import arcpy

'''
This script will count the number of occurences of a value in a field ("field_in") and write them to a 
new field ("field_out")
'''

arcpy.env.workspace = r"C:\Users\jpilbeam\Downloads\DuplicateTesting.gdb\DuplicateTesting.gdb" #path to GDB goes here
infeature = "backup_02232021" #name of feature class goes here
field_in = "name" #this is the alias of the field. Name: is the actual name
field_out = "COUNT_"+field_in
arcpy.AddField_management(infeature, field_out,"SHORT")

lista= []
cursor1=arcpy.SearchCursor(infeature)
for row in cursor1:
    i=row.getValue(field_in) #&amp;lt;-- where exception is thrown using field name in field_in variable
    lista.append(i)
del cursor1, row

cursor2=arcpy.UpdateCursor(infeature)
for row in cursor2:
    i=row.getValue(field_in)
    occ=lista.count(i)
    row.setValue(field_out, occ)
    cursor2.updateRow(row)
del cursor2, row
print("----done----")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;EDIT: &lt;/STRONG&gt;Using the alias, I let the code run for like 15-20 mins and it finished with no errors! So, I guess it just needs that long with all these records?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2021 17:30:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1029623#M60059</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2021-02-23T17:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to indentify duplicate or unique value in Pro RuntimeError: Error 999999</title>
      <link>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1029650#M60062</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/find-identical.htm" target="_blank"&gt;Find Identical (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;is useful as well, or for comparison&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2021 18:18:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1029650#M60062</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-02-23T18:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to indentify duplicate or unique value in Pro RuntimeError: Error 999999</title>
      <link>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1029698#M60063</link>
      <description>&lt;P&gt;Well if it works... Still confusing that it's taking an alias rather than the fieldname but the old cursors are pretty alien to me.&lt;/P&gt;&lt;P&gt;I'd recommend looking at Dan's suggestion as it may be faster.&lt;/P&gt;&lt;P&gt;If not and you're still looking for speed, I'm not sure the script itself is designed for performance.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First it has an old cursor&amp;nbsp; &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/searchcursor.htm" target="_blank"&gt;SearchCursor—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;rather than the faster arcpy.da cursor has superceded it.&amp;nbsp; Also in the cursor initiation, you can probably get a boost by limiting the fields argument to just the field(s) you need - at the moment, the entire row is returned.&lt;/P&gt;&lt;P&gt;Perhaps the .count method on the list is optimal, but I do wonder if there's a better way than appending everything to a list then counting it after (although this is exactly how I'd write my own junk code just to do something then gather dust for eternity!).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2021 19:23:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1029698#M60063</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-02-23T19:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to indentify duplicate or unique value in Pro RuntimeError: Error 999999</title>
      <link>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1029754#M60065</link>
      <description>&lt;P&gt;For unique, duplicates etc, numpy is the way to go.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
from arcpy.da import TableToNumPyArray, NumPyArrayToTable
f = r"C:\arcpro_npg\npg\Project_npg\npgeom.gdb\sample_10k"  # --- a 10k -ish table
arr = TableToNumPyArray(f, "*")  # --- produce the array
flds = arr.dtype.names  # ---- to get all the fields
sub = arr[['County', 'Town_class', 'Facility']]  # --- subsample of the  fields
uni, idx, cnts = np.unique(sub, True, return_counts=True)  # --- perform unique

uni # ---- unique records for those 3 fields
array([('A', 'A_', 'Hall'), ('A', 'A_', 'Hosp'), ('A', 'B_', 'Hall'),
       ('A', 'B_', 'Hosp'), ('A', 'C_', 'Hall'), ('A', 'C_', 'Hosp'),
       ('B', 'A_', 'Hall'), ('B', 'A_', 'Hosp'), ('B', 'B_', 'Hall'),
       ('B', 'B_', 'Hosp'), ('B', 'C_', 'Hall'), ('B', 'C_', 'Hosp'),
       ('C', 'A_', 'Hall'), ('C', 'A_', 'Hosp'), ('C', 'B_', 'Hall'),
       ('C', 'B_', 'Hosp'), ('C', 'C_', 'Hall'), ('C', 'C_', 'Hosp'),
       ('D', 'A_', 'Hall'), ('D', 'A_', 'Hosp'), ('D', 'B_', 'Hall'),
       ('D', 'B_', 'Hosp'), ('D', 'C_', 'Hall'), ('D', 'C_', 'Hosp')],
      dtype={'names':['County','Town_class','Facility'], 'formats': 
                     ['&amp;lt;U4','&amp;lt;U12','&amp;lt;U16'], 'offsets':[8,24,72],
                      'itemsize':2184})

cnts # ---- counts for each unique record
array([590, 605, 465, 448, 442, 481, 554, 583, 446, 426, 491, 469, 607,
       621, 433, 468, 448, 457, 183, 198, 121, 162, 158, 140], dtype=int64)

sum(cnts)
9996

# ----
# NumPyArrayToTable  =====&amp;gt;  and back to Arc-world&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 23 Feb 2021 21:04:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1029754#M60065</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-02-23T21:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to indentify duplicate or unique value in Pro RuntimeError: Error 999999</title>
      <link>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030051#M60092</link>
      <description>&lt;P&gt;Thanks for the replies! I didn't even notice I was using the old cursor (was in a rush). So, now that I'm revamping this code, I'm suck with an error :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;infeature = r"C:pathtofile\file.gdb\file" #name of feature class goes here
fields = ["Name:", "Location", "Email Address", "Cell Phone Number:", 
          "Home Phone Number:"] 

with arcpy.da.SearchCursor(infeature, fields) as cursor1:
    for row in cursor1:
        print(row)&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;Traceback (most recent call last):
  File "\pathto\DuplicateFields_updated.py", line 18, in &amp;lt;module&amp;gt;
    for row in cursor:
RuntimeError: An invalid SQL statement was used. [SELECT OBJECTID,Name:,Location,Email Address,Cell Phone Number:,Home Phone Number: FROM backup_02232021_NEW]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the fieldnames, not the aliases. Because they're strings, I don't believe the spaces matter?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 16:41:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030051#M60092</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2021-02-24T16:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to indentify duplicate or unique value in Pro RuntimeError: Error 999999</title>
      <link>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030072#M60093</link>
      <description>&lt;P&gt;I wouldn't think they're the correct fieldnames, as many of them contain spaces and colons, which I believe makes them invalid.&amp;nbsp; I would double-check the actual fieldnames in the first instance, as the error seems to allude to that.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 17:02:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030072#M60093</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-02-24T17:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to indentify duplicate or unique value in Pro RuntimeError: Error 999999</title>
      <link>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030123#M60094</link>
      <description>&lt;P&gt;The weird thing is, these are unmistakably the fieldnames. This feature class was created by Survey123 Connect. And, I can't change them as they're part of a live survey.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 18:41:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030123#M60094</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2021-02-24T18:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to indentify duplicate or unique value in Pro RuntimeError: Error 999999</title>
      <link>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030128#M60095</link>
      <description>&lt;P&gt;Can you send a screenshot?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 18:52:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030128#M60095</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-02-24T18:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to indentify duplicate or unique value in Pro RuntimeError: Error 999999</title>
      <link>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030138#M60096</link>
      <description>&lt;P&gt;perhaps there are leading or trailing spaces in the field names if it was produced in Survey123.&amp;nbsp; That would be a fieldname killer for sure.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 19:08:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030138#M60096</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-02-24T19:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to indentify duplicate or unique value in Pro RuntimeError: Error 999999</title>
      <link>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030184#M60097</link>
      <description>&lt;P&gt;This is from the table. I copied the field name directly from the table and pasted into my list.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fields.png" style="width: 800px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/6827i375F5618FA975831/image-size/large?v=v2&amp;amp;px=999" role="button" title="fields.png" alt="fields.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 20:32:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030184#M60097</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2021-02-24T20:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to indentify duplicate or unique value in Pro RuntimeError: Error 999999</title>
      <link>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030186#M60098</link>
      <description>&lt;P&gt;Apparently, I'm braindead? I guess they were the aliases... whoops.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 20:33:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030186#M60098</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2021-02-24T20:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to indentify duplicate or unique value in Pro RuntimeError: Error 999999</title>
      <link>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030191#M60099</link>
      <description>&lt;P&gt;Thanks for the reply about using numpy. I'm not that advanced yet, but i'll earmark the post.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 20:41:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-indentify-duplicate-or-unique-value-in-pro/m-p/1030191#M60099</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2021-02-24T20:41:48Z</dc:date>
    </item>
  </channel>
</rss>

