I have two values, one date and one time, I would like to only calculate my new field if the value for the field is NULL. How do I do so using ArcPy? My current code reads as.
calcExpression = "!ORIGDTDATE!+\" \"+ !ORIGDTTIME!" arcpy.CalculateField_management(self.line_ticket_feature_class,"emergency_overdue",calcExpression,"PYTHON_9.3") arcpy.CalculateField_management(self.poly_ticket_feature_class,"emergency_overdue",calcExpression,"PYTHON_9.3")
Something like this should work.
import arcpy date = 'date_field' time = 'time_field' new = 'new_field' feature = r'path to dataset' with arcpy.da.UpdateCursor(feature, [new, date, time]) as cursor: for row in cursor: if row is None: row = str(row) + '/' + str(row) # can separate the fields with anything you'd like cursor.updateRow(row)