Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Archives Historic SAP Numbers
- import arcpy
- fc = "U:/Data/Leases.gdb/LeasePlans"
- changes = "U:/Data/To_be_Deleted.csv"
- #New Field Criteria
- field_Name = "Status"
- field_Nametype = "Text"
- field_NameVal = arcpy.ValidateFieldName(field_Name)
- #Adds the new field if it doesn't already exist
- fList = arcpy.ListFields(fc,field_Name)
- if not fList:
- arcpy.AddField_management(fc, field_Name, field_Nametype, "", "", "")
- #List comprehension for IDs
- ids = [i for i, in arcpy.da.SearchCursor
- (changes, "SAPNO") if i != None]
- Relevant_Fields = ['Property_Ref', 'Status']
- #update cursor to Insert 'Archived' rows
- with arcpy.da.UpdateCursor (fc, Relevant_Fields) as cursor:
- for SAPNO, in cursor:
- if SAPNO in ids:
- row[1] = 'Archived'
- cursor.UpdateRow()
- del cursor
Add Comment
Please, Sign In to add comment