I need to add about 500 values (street names) to a domain called streetxx. The street names are in a csv file called streetname.csv. I'm using AarcMap 10.8.2. My code is very simple yet I'm getting a StopIteration error. What am I doing wrong? Thanks for the help in advance.
import arcpy
import csv
# Set the path to the CSV file and the geodatabase
csv_file = r"J:\OMS_Upgrade\Water\streetname.csv"
gdb = r"J:\OMS_Upgrade\OMSTest.mdb"
# Set the name of the feature class and field to be updated
fc = "Water_Mains"
field = "Streetxx"
# Use the arcpy.da.UpdateCursor() method to update the feature class
with arcpy.da.UpdateCursor(gdb + "\\" + fc, [field]) as cursor:
# Open the CSV file and read the values
with open(csv_file, "r") as f:
reader = csv.reader(f)
# Skip the header row
next(reader)
# Iterate over the rows in the CSV file
for row in reader:
# Update the field with the value from the CSV file
cursor.updateRow([row[0]])
Here is the error message:
Traceback (most recent call last):
File "J:\OMS_Upgrade\Scripts\Update_Domain.py", line 23, in <module>
cursor.updateRow([row[0]])
StopIteration: iteration not started