I get a lot of shapefiles with no metadata. Grrr. Often there are tons of table columns (fields) with no description of what the column is for or what the coded values mean. Is there an easy way to export a table so that the domain of unique values are listed per column? In other words, if a table has two columns, say, Color and Shape, is there a way to export a table that lists all the unique values in Color and all the unique values in Shape? I know a quick way is to open "Select by Attribute" in ArcMap, select a field and click "Get Unique Values" to see the list of unique attributes within the field. It would be great if there was an easy way to export a table of these unique values by column (field).

To keep it simple, I'm just interested in text or string fields.

  • Are you using Python? – Aaron Apr 20 '20 at 18:06
  • Which ArcGIS version do you have? – BERA Apr 20 '20 at 18:11
  • 1
    There's easier ways than playing around in the UI for value selection to find unique values. There's Summary Statistics (Statistics_analysis), and Frequency (Frequency_analysis ) for those with Advanced licenses, but you can also do this with five lines of DA Search Cursor code using a set to compile a list of unique values or a dictionary to count occurrences. – Vince Apr 20 '20 at 18:27
  • I'm not opposed to using Python, though I'm not great at scripting. I'm on ArcGIS Desktop 10.8, or ArcGIS Pro 2.5. Only have a standard license. Thanks! – Lance Apr 20 '20 at 20:26
  • For an initial check, open the attribute table, right click on the field, and run Summary. – danak Apr 24 '20 at 21:58

The only solution is Python with mighty Pandas:

import pandas as pd
import os, simpledbf
from simpledbf import Dbf5

allFields=pd.DataFrame(columns = ["FOLDER","FILE","FIELD","VALUE"])
# traverse root directory, and list directories as dirs and files as files
for root, dirs, files in os.walk("C:/scratch/backup"):
    path = root.split(os.sep)
    for file in files:
        if file[-4:]!=".dbf":continue
##        print root, file
        dbf = Dbf5(root+os.sep+file)
        df = dbf.to_dataframe()
        for field in list(df):
            fieldType = df[field].dtypes
            if fieldType!='object':continue
            print field
            for item in df[field].unique():
allFields.to_csv (r'c:\SCRATCH\output.csv', index = None, header=True)

I tested it on folder with few shapefiles, might take a long time in your case. Use filters on output.csv in Excel:

enter image description here

Note you'll need to install simpledbf. My bad, more than 5 lines, learning curve.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.