![]() ![]() You have defined usesKey as a list of all the keys in your dictionary. I think your use of the 'in' statement on line 39 is problematic as Joshua suggests: if usesKey in row : Natalia - your use of list comprehension on line 12 is impressive. The weird thing is that I have both of the columns.Īlso, not sure if the overall code has more errors.Ĭould someone help me with this? I need to finish this today and I have no idea on how to continue. RuntimeError: A column was specified that does not exist. When I try to run the code I am getting this first error: Traceback (most recent call last):įile "D:/APRX_MXDS/USA_Parcels_2019_Project/Scripts/Dictionary Key() method_2.py", line 44, in If a feature in field DOR_UC is equal to 000 then the feature value in field TEST would be "Vacant Residential - with/without extra features". So the code would go something like this: ![]() To start testing the script I created a field called "TEST" where I want to put the value part of the dictionary. To do this I've created a dictionary where the key is the code and the value is the sentence (See attached csv). I need to assign their meaning and delete the codes. See image below for fc attribute's table:Įach of those codes has a meaning in the form of a sentence. updateRow ( ) įield DOR_UC currently has some codes that I need to convert into a sentence. UpdateCursor (fc, fields ) as cursor : for row in cursor : if usesKey in row :Ĭursor. values ( ) ) # List of fieldsįields = with arcpy. overwriteOutput = True # feature classįc = "testing_fc" # printing all fields in fcįields = print (fields ) # dictionary workspace = r "D:\APRX_MXDS\USA_Parcels_2019_Project\test_featureclasses.gdb"Īrcpy. # script to assign values to features in one field based on a value in the dictionaryĪrcpy. I created the script below to change the feature values of a field called "DOR_UC" and as you can see there is a list of other fields where I need to do something similar - that's why there is a long list of other fields. I am trying to use python dictionaries to change the feature values of different fields.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |