I'm working with a versioned feature class in ArcGIS Pro, which is connected to an enterprise SDE database. My goal is to iterate through all the records and update fields with only blank or whitespace values to Null.
To start, I'm using the script below to return the OBJECTID for records with whitespace values of the feature class within my active map frame. However, it seems like the script is referencing the non-versioned feature class and not returning the expected results from my test cases.
import arcpy
# Set the workspace and feature class
arcpy.env.workspace = r"file_path_to_connection_file.sde"
feature_class = "fc_A"
# Get the list of fields in the feature class
fields = arcpy.ListFields(feature_class)
# Start a search cursor to iterate through the records
with arcpy.da.SearchCursor(feature_class, ["OBJECTID"] + [field.name for field in fields if field.type == "String"]) as cursor:
for row in cursor:
object_id = row[0]
for i, value in enumerate(row[1:], start=1):
if value is not None and value.strip() == "":
print(f"Record with OBJECTID {object_id} has a blank field: {fields[i].name}")
print("Script completed.")Is there a specific way to ensure the script is referencing the versioned feature class? Any suggestions on why my test cases might not be returning as expected?