I have managed to get my previous update cursor to work without any hiccups. All I have done is change the fields the script needs to look for. The error I am getting is:
RuntimeError: A column was specified that does not exist.
The column exists in the attribute table the runtime error is on line 52 of the script (for row in cursor) : Here is the script
#Script to add in a new period field and base the values on the existing HER period column
import arcpy
#Adjust these two lines:
fc = arcpy.GetParameterAsText(0)
fields = ['PeriodRang','PeriodFrom']
#Dictionary of old and new value. Add all your values here, instead of many if/elifs
remap = {
'Palaeolithic':'Palaeolithic',
'Later Prehistoric':'Prehistoric',
'Prehistoric':'Prehistoric',
'Mesolithic':'Mesolithic',
'Late Mesolithic to Late Bronze Age':'Mesolithic',
'Neolithic':'Neolithic',
'modern':'Modern',
'Unknown':'Undated',
'Undated':'Undated'
}
with arcpy.da.UpdateCursor(fc, fields) as cursor:
for row in cursor:
if row[0] in remap: #row[0] is the value of periodRang field. This if, is checking whether the value exist in the remap dictionary
row[1] = remap[row[0]]
cursor.updateRow(row) ```
arcpy.Exists(fc)
andarcpy.ListFields(fc)
(with case-insensitive comparison withfields
) validation to your script.