<?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: Writing Unique Attribute Field Values to csv in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512152#M40252</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am familiar with sets in python. I attempted applying it to the solution posted on SE, but because the code writes by row instead of writing by column, applying set only extracts the unique values on each ROW. I would need it to extract the unique values on each COLUMN.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 May 2015 20:56:09 GMT</pubDate>
    <dc:creator>benberman</dc:creator>
    <dc:date>2015-05-21T20:56:09Z</dc:date>
    <item>
      <title>Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512148#M40248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to do something similar to the URL linked below. The first answer writes out all the values for each attribute field, using the attribute names as the column headers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://gis.stackexchange.com/questions/42433/how-to-export-only-certain-columns-to-a-csv-file-in-arcgis" title="http://gis.stackexchange.com/questions/42433/how-to-export-only-certain-columns-to-a-csv-file-in-arcgis"&gt;python - How to export only certain columns to a CSV file in ArcGIS? - Geographic Information Systems Stack Exchange&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I want to be able to do is write out the unique values for each attribute field, using the attribute names as the column headers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 19:41:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512148#M40248</guid>
      <dc:creator>benberman</dc:creator>
      <dc:date>2015-05-21T19:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512149#M40249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may want to look at &lt;A href="https://docs.python.org/2/library/sets.htmlhttp://" rel="nofollow noopener noreferrer" target="_blank"&gt;sets in python&lt;/A&gt;. They essentially take a list of items and return a set of unique items in that list. E.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; myList = [1, 3, 6, 1, 4, 7, 6)
&amp;gt;&amp;gt;&amp;gt; mySet = set(mylist)
&amp;gt;&amp;gt;&amp;gt; mySet
set([1, 3, 6, 4, 7])
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe post some of your existing code and we can see what you need.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:25:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512149#M40249</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2021-12-11T22:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512150#M40250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So what is different between the answer given to that stack exchange question, and what you are trying to do?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN class="kwd"&gt;import&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; arcpy&lt;BR /&gt;&lt;BR /&gt;fc &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;'C:\\antenna_shp\\cables.shp'&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;CSVFile&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;'C:\\antenna_shp\\FinalOutput.csv'&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&lt;BR /&gt;fields &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;[&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;f&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;name &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;for&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; f &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;in&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; arcpy&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;ListFields&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;fc&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)]&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;for&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; i&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;f &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;in&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; enumerate&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;fields&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;):&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;if&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; f &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;==&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;'Shape'&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;or&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; f &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;==&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;'Shape_Length'&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;or&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; f &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;==&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;'OBJECTID'&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;del&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; fields&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;[&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;i&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;]&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;with&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; open&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;CSVFile&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;'w'&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;as&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; f&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; f&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;write&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="str"&gt;','&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;join&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;fields&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)+&lt;/SPAN&gt;&lt;SPAN class="str"&gt;'\n'&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="com"&gt;#csv headers&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; with&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; arcpy&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;da&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;SearchCursor&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;fc&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; fields&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;as&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; cursor&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; row &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;in&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; cursor&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;write&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="str"&gt;','&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;join&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;([&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;str&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;r&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;for&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; r &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;in&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; row&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;])+&lt;/SPAN&gt;&lt;SPAN class="str"&gt;'\n'&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 19:58:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512150#M40250</guid>
      <dc:creator>SepheFox</dc:creator>
      <dc:date>2015-05-21T19:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512151#M40251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As I have mentioned in my opening post, the SE solution pulls ALL the values in any given attribute field. I am only interested in UNIQUE values.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 20:53:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512151#M40251</guid>
      <dc:creator>benberman</dc:creator>
      <dc:date>2015-05-21T20:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512152#M40252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am familiar with sets in python. I attempted applying it to the solution posted on SE, but because the code writes by row instead of writing by column, applying set only extracts the unique values on each ROW. I would need it to extract the unique values on each COLUMN.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 20:56:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512152#M40252</guid>
      <dc:creator>benberman</dc:creator>
      <dc:date>2015-05-21T20:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512153#M40253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds a lot like a summary table and then a pivot table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 21:05:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512153#M40253</guid>
      <dc:creator>SepheFox</dc:creator>
      <dc:date>2015-05-21T21:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512154#M40254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The enumerate block does not even need to be in there, just add a conditional at the end of the fields list, per the snippet below. I also added the "set()" method to the final line. Because the code is writing by row instead of by column, it is extracting the unique values by row. I can't seem to get it to extract unique values by column for some reason.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
fc &lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;'C:\\antenna_shp\\cables.shp'&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;CSVFile&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;'C:\\antenna_shp\\FinalOutput.csv'&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;/SPAN&gt;
fields = [f.name for f in arcpy.ListFields(fc) if f.type != 'Geometry']
with open(CSVFile, 'w') as w:
&amp;nbsp;&amp;nbsp;&amp;nbsp; w.write(','.join(fields)+'\n') 
&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor(fc, fields) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; w.write(','.join(set([str(r) for r in row]))+'\n')&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:25:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512154#M40254</guid>
      <dc:creator>benberman</dc:creator>
      <dc:date>2021-12-11T22:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512155#M40255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sure, there are ways to do this through arc tools. I was just interested in more of a pythonic way of doing it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 22:37:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512155#M40255</guid>
      <dc:creator>benberman</dc:creator>
      <dc:date>2015-05-21T22:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512156#M40256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm working on something similar.&amp;nbsp; I'm writing the items that I want to a variable.&amp;nbsp; I then check to see it it's unique, and append it to my list if not.&amp;nbsp; the I sort the list.&amp;nbsp; then I write it to my .csv.&amp;nbsp; In short...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;outFile = r"d:/_dataTest/myoutput.csv"&amp;nbsp; 

f = open(outFile, "w") 

print ("File is open:&amp;nbsp; " + str(not f.closed))

f.write("Type, TOCRef, FullPath, newPathn") 

uniqueList = []

for root, dirs, files in os.walk(rootDir): 
&amp;nbsp;&amp;nbsp;&amp;nbsp; if something: #do stuff and create various anItem's
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; anItem = ("blah", "blah", "blah") # creates an item with the fields or variable values I want

&amp;nbsp;&amp;nbsp;&amp;nbsp; if anItem not in uniqueList:&amp;nbsp;&amp;nbsp;&amp;nbsp; # created tuple list of uniq combinations
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uniqueList.append(anItem)&amp;nbsp; #appends the item only if it is completely unique

#once all is done and everything is appended and unique
uniqueList.sort()&amp;nbsp; # sorts the list, order Type, Path, TOC

for item in uniqueList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # creating output as Type, TOC, Path

&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write("{},{}, {}\n".format(item[0], item[2], item[1]))
f.close()&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I trimmed this from a much larger script so obviously it will not run as is.&amp;nbsp; Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:25:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512156#M40256</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-11T22:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512157#M40257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Numpy has tools to find unique values in files.&amp;nbsp; This example gives you a sniff at what you can do.&amp;nbsp; When working with tabular data, use numpy, it is way faster and there is more that can be don​e...and yes...it even works with columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The example below simply finds the unique values in two columns, one integer, the other string....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import numpy as np
np.set_printoptions(edgeitems=4,linewidth=60,precision=2,suppress=True,threshold=10)
X = [6.0,7,8,3,6,2,9,2,8,3]
Y = [0.0,9,6,2,1,5,4,1,4,5]
Group = [4,2,1,4,3,2,2,3,4,1]
Text = ['a','c','b','a','a','b','a','c','d','b']
dt = [('X','f8'),('Y','f8'),('Group','i4'),('Text','|S5')]
arr = np.array(zip(X,Y,Group,Text),dtype=dt)
print('\nInput array: X,Y,Group,Text,\n{}'.format(arr))
for col in ['Group','Text']:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arr_where,idx= np.unique(arr[col],return_index=True)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print('Unique results==&amp;gt; Column: {}\n&amp;nbsp; Unique: {}\n&amp;nbsp; Indices: {}'.format(col,arr_where,idx))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;give it whirl&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:25:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512157#M40257</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T22:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512158#M40258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is this what you're looking for? It might help to see an example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Input table:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(198, 198, 198); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;PrimaryKey&lt;BR /&gt;&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;SomeAttr&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;OtherSomething&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;NewVal&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;123&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;ABC&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;LOW&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;6.123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;456&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;ABC&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;MED&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;15.456&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;789&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;ABC&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;HIGH&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;24.789&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;321&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;CBA&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;LOW&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;6.321&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;654&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;CBA&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;MED&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;15.654&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output CSV:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(198, 198, 198); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;PrimaryKey&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;SomeAttr&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;OtherSomething&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;NewVal&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;123, 456, 789, 321, 654&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;ABC, CBA&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;LOW, MED, HIGH&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;6.123, 6.321, 15.456, 15.654, 24.789&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 23:34:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512158#M40258</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-05-21T23:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512159#M40259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;using my example&lt;EM&gt; a&lt;/EM&gt;bove, just add the code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Groups = (np.unique(arr['Group'])).tolist()
Classes =&amp;nbsp; (np.unique(arr['Text'])).tolist()
print('Unique groups: {}\nUnique text: {}'.format(Groups,Classes))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gives&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Unique groups: [1, 2, 3, 4]&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Unique text: ['a', 'b', 'c', 'd']&lt;/P&gt;&lt;P&gt;​which you could obviously add to a field or dictionary or whatever&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:25:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512159#M40259</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T22:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512160#M40260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan's way is no doubt better, but since I don't know numpy, what I meant is to read the values of each column into a list (arcpy.da.SearchCursor), then use set on that list. You can then turn the set back into a list if that is more appropriate for your needs. Repeat for each column. This will give you a a collection of sets (or lists) of unique values for each column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you're in an environment where you can use SQL queries, you could also just issue a SELECT DISTINCT command. &lt;A href="https://pypi.python.org/pypi/python-sqlhttp://"&gt;First link&lt;/A&gt; on googling 'python sql'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 May 2015 12:29:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512160#M40260</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2015-05-22T12:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512161#M40261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can actually include a DISTINCT statement as a "sql prefix" in the sql_clause parameter of the arcpy.da.SearchCursor(). I've used it before and it works quite well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;sqlprefix = "DISTINCT MyFieldName"
sqlpostfix = "ORDER BY MyFieldName"
myField_Distinct = tuple(
&amp;nbsp;&amp;nbsp;&amp;nbsp; row[0] for row in arcpy.da.SearchCursor(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "MyGeodatabaseTableName",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ["MyFieldName"],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sql_clause=(sqlprefix, sqlpostfix)
&amp;nbsp;&amp;nbsp;&amp;nbsp; )
)&lt;/PRE&gt;&lt;P&gt;You could do that for each field and write it out however you like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But you did say you didn't want to use arcpy, so... maybe go with Dan's NumPy example.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:25:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512161#M40261</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-11T22:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512162#M40262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Correct, except I'm trying to write it out each unique value in sucessive rows, one value per cell, instead of all on the same row(multiple values in the same cell).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 May 2015 17:35:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512162#M40262</guid>
      <dc:creator>benberman</dc:creator>
      <dc:date>2015-05-22T17:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512163#M40263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's my solution.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy
&amp;nbsp;&amp;nbsp;&amp;nbsp; import os
&amp;nbsp;&amp;nbsp;&amp;nbsp; import csv
&amp;nbsp;&amp;nbsp;&amp;nbsp; import itertools
&amp;nbsp;&amp;nbsp;&amp;nbsp; import collections

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Local variables
&amp;nbsp;&amp;nbsp;&amp;nbsp; workingDir = r"N:\TechTemp\BlakeT\Work"
&amp;nbsp;&amp;nbsp;&amp;nbsp; workingGDB = os.path.join(workingDir, "TEMP.gdb")
&amp;nbsp;&amp;nbsp;&amp;nbsp; inputTable = os.path.join(workingGDB, "TestingFc")
&amp;nbsp;&amp;nbsp;&amp;nbsp; outputCSV = os.path.join(workingDir, "MyOutput.csv")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get list of usable field names (exclude OID and SHAPE fields)
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldNames = [
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.name for f in arcpy.ListFields(inputTable)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if f.type != "Geometry" and f.editable == True
&amp;nbsp;&amp;nbsp;&amp;nbsp; ]

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Populate dictionary with field names and their distinct values
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldVals_Distinct = collections.OrderedDict()
&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in fieldNames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Processing {}".format(field))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Get distinct field values and populate dictionary
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sqlprefix = "DISTINCT {}".format(field)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sqlpostfix = "ORDER BY {}".format(field)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldVals_Distinct[field] = [
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[0] for row in arcpy.da.SearchCursor(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inputTable,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [field],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sql_clause=(sqlprefix, sqlpostfix)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ]

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create CSV
&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Using the w mode will overwrite an existing file or create a new one
&amp;nbsp;&amp;nbsp;&amp;nbsp; with open(outputCSV, "w") as csvfile:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; csvwriter = csv.writer(csvfile, delimiter=',', lineterminator='\n')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Write field name header line
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; csvwriter.writerow(fieldVals_Distinct.keys())
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Zip distinct values together for all fields and write to CSV
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldVals_zipped = itertools.izip_longest(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *fieldVals_Distinct.values(),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fillvalue=None
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; csvwriter.writerows(list(fieldVals_zipped))


if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ordered dictionary may not be necessary, but from my initial testing, it sometimes changed the order of stuff when zipping all of the values together at the end. Thank you to &lt;A href="https://community.esri.com/migrated-users/3116" target="_blank"&gt;Dan Patterson&lt;/A&gt;​ for the idea to use zip (or zip_longest in this case).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:25:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512163#M40263</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-11T22:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512164#M40264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Blake&lt;/P&gt;&lt;P&gt;Very nice job...!!!&lt;/P&gt;&lt;P&gt;I will put forth this little ditty in the hopes that you can see that a search cursor can be completely replaced if desired and everything brought into numpy by using TableToNumPyArray (and its reverse equivalent).&lt;/P&gt;&lt;P&gt;The example produces 3 columns of data... ID,Single,Double with ID being...well...an ID field and the last 2 fields just random letters.&amp;nbsp; I find it easier to use data that I can control for testing.&amp;nbsp; I do like the use of the OrderedDict and Counter.&amp;nbsp; Anyhow, have some fun with this.&amp;nbsp; I will post a follow up on my blog that incorporates time testing, but I thought this would amuse you and others in the interim.&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import numpy as np
import string
import random
from collections import Counter, OrderedDict
np.set_printoptions(edgeitems=4,linewidth=60,precision=2,suppress=True,threshold=10)
# testing stuff...................................................
classes = string.uppercase[:5]&amp;nbsp; # first 5 letters of the alphabet
N = 100
col1 = [random.choice(classes) for i in range(N)]
col2 = [random.choice(classes)*2 for i in range(N)]
ID = np.arange(N)
data = zip(ID,col1,col2)
arr = np.array(data,dtype=[("ID","int32"),("Single","|S5"),("Double","|S5")])
#.................................................................
# real stuff ... see
#&amp;nbsp; arr = TableToNumPyArray(in_table,field_names,{where_clause},
#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {skip_nulls},{null_value})
#
print("\nInput array:\n{}\ndtype: {}".format(arr,arr.dtype))
fields = arr.dtype.names&amp;nbsp; # array field names
for f in fields:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if arr&lt;F&gt;.dtype.char == 'S':&amp;nbsp;&amp;nbsp; # could include other field types@
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = Counter(arr&lt;F&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; keys = c.keys()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; od = OrderedDict((x,c&lt;X&gt;) for x in keys)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("\nField: {}\n&amp;nbsp; Counter: {}\n&amp;nbsp; OrderedDict: {}".format(f,c,od))
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("\nField: {}, type: {} not string type... darn ...".format(f,arr&lt;F&gt;.dtype))&lt;/F&gt;&lt;/X&gt;&lt;/F&gt;&lt;/F&gt;

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:25:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512164#M40264</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T22:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512165#M40265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Blake and Dan! This helps a lot!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 May 2015 21:39:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512165#M40265</guid>
      <dc:creator>benberman</dc:creator>
      <dc:date>2015-05-22T21:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512166#M40266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can see the utility of NumPy, but I just haven't learned it yet. I also did not know about &lt;A href="https://docs.python.org/2/library/collections.html#collections.Counter"&gt;Counter&lt;/A&gt;. Every little bit helps in learning these new things. Thank you for posting the follow-up &lt;A href="https://community.esri.com/migrated-users/3116"&gt;Dan Patterson&lt;/A&gt;!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 May 2015 21:52:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512166#M40266</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-05-22T21:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Writing Unique Attribute Field Values to csv</title>
      <link>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512167#M40267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Blake...there is some older stuff here from Aug 2014...I am currently updating stuff, so it isn't uptodate&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migration-blogpost/1428"&gt;Collections in numpy: producing frequency distributions and graphing&lt;/A&gt; ​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 May 2015 22:12:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/writing-unique-attribute-field-values-to-csv/m-p/512167#M40267</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-05-22T22:12:31Z</dc:date>
    </item>
  </channel>
</rss>

