I had a problem trying to do a field calculation with field values that had <Null> ‘s. You need to convert these to strings first apparently!! Read below!
When Calculate Field evaluates your expression, it looks for null values and if any are found, the expression is not evaluated. This prevents divide-by-zero errors and other undefined operations.
If your field contains null values, you need to turn it into a string (using str()) in the expression, even if it’s already a string field e.g
Plus, if you want to return a null value back to the cell, then just return “None” – without quotes 🙂
When running a script sometimes you can get an error, especially when trying to delete a featureclass – something like:
ExecuteError: ERROR 000601: Cannot delete Database Connections\foo.sde\foo.barfc. May be locked by another application.
Use the following to get rid of any SDE connections:
Skipping optional arguments using keyword arguments when running Python tools
arcpy.AddField_management("schools", "school_id", "LONG", field_is_nullable="NON_NULLABLE")
Quick way to get a DataReader result into a Dictionary:
Dictionary<string, object> surveyDict = new Dictionary<string, object>();
aDict = Enumerable.Range(0, dr.FieldCount).ToDictionary(dr.GetName, dr.GetValue);