1

I'm using an InsertCursor to insert rows into a feature class. One of the fields in the source data may contain a NULL data value. The destination feature class requires a date - it is not nullable. In the dictionary of values I pass to the InsertCursor, I insert a string value of "01/01/1970 00:00:00". When the cursor tries to insert the row, I get an error that says the column cannot be null.

How do I get the InsertCursor to insert the date string as a date?

2
  • Why not making the field Nullable? Commented Feb 26, 2015 at 16:07
  • @FaridCher Yeah, that would be great. Not an option at the moment. I'm a small cog in a very large machine and even that change requires mass coordination. I'll likely see the return of glaciers before that change is complete. Commented Feb 26, 2015 at 16:10

1 Answer 1

1

Start by checking if the value is None. If it is, replace the value with this

if rowData[idx] is None:
     rowData[idx] = datetime.datetime(1970, 1, 1, 0, 0)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.