0

I want to create ArcGIS geodatabase domains from a CSV file.The problem is that my output says field values in the row are "None". It doesn't recognize the values in my CSV file.

Any ideas ?

Here's the code I am using :

import arcpy
import csv
arcpy.env.workspace = "D:/DATA"
gdb                 = "NEW.sde"
csvfile             = "D:/DATA/Domains.csv"
domains = []
rows = []

with open(csvfile, 'r') as csvfile:
    reader = csv.DictReader(csvfile)
    for row in reader:
        try:
           domains.append(row.get('domain'))
           rows.append(row)
        except KeyError:
           rows = [row]

 domains = list(set(domains))
 print("Identified %s unique domains" % len(domains))
 print("Identified %s codes" % len(rows))


 print("Creating codes:")
 for row in rows:
     print("%s\t%s\t%s" % (row.get('domain'), row.get('code'), row.get('code_description')))
     arcpy.AddCodedValueToDomain_management(gdb, row['domain'], row['code'],  row['code_description'])

print("Done")

And here's my CSV File:

[![enter code here][1]][1]
3
  • Can you add a sample of your data? What is the encoding of your CSV?
    – NettaB
    Commented Aug 17, 2020 at 8:40
  • Hi, i added a sample of my csv file
    – MAR
    Commented Sep 28, 2020 at 15:28
  • Hi, please recheck your file - I'm seeing "[![enter code here][1]][1]"
    – NettaB
    Commented Sep 29, 2020 at 11:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.