Hi,
I have a csv as follow;
ID NAME Category Model
H1 Bridge BG AB1
H2 Tunnel TL AB2 etc etc
I have a geodatabase with multiple feature classes:
Working.gdb (within each FC there is a FILENAME field with the Model number)
FcOne (FILENAME: AB1, ID: Empty, NAME: Empty, Category: Empty)
FcTwo etc etc
I am trying to join the csv to all the FCs and field calculate the empty fields in the gdb with those in the csv.
I am using Blakes code :
#Join CSV and populate fields
csv_values = {
row[3]: {"ID": row[0], "NAME": row[1], "Category": row[2]}
for row in arcpy.da.SearchCursor(Add_CSV, ["ID", "NAME", "Category", "Model"])
}
for fc in fcList:
with arcpy.da.UpdateCursor(fc, ["FILENAME", "ID", "NAME", "CATEGORY"]) as u_cursor:
for filename, id, name, category in u_cursor:
csv_record = Add_CSV.get(filename)
assert csv_record, "No value found for {} filename {} in CSV".format(fc, filename)
id = csv_record["ID"]
name = csv_record["NAME"]
category = csv_record["Category"]
u_cursor.updateRow([filename, id, name, category])
I get the following error:
csv_record = Add_CSV.getValue(filename)
AttributeError: 'str' object has no attribute 'getValue'
Not sure how to fix this. Can you assist?