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[0] is None:
row[0] = str(row[1]) + '/' + str(row[2]) # can separate the fields with anything you'd like
cursor.updateRow(row)