Hi,
So I came across a very strange issue, one that I never had issues with previously and then all of sudden I started having issues. The issue is the length field for one of the feature classes isn't reading for some reason. It was able to read in the past but now it doesn't seem to be reading it. I have tested it in a notebook as well as a standalone script.
import arcpy
import sys
import os
workspace = *
sewerin_fcs = *
ws_split = os.path.split(workspace)
fcs = []
walk = arcpy.da.Walk(workspace, datatype="FeatureClass")
for dirpath, dirnames, filenames in walk:
for filename in filenames:
#Get feature class name
fcsname = os.path.basename(filename)
name = os.path.splitext(fcsname)
y = name[1].lstrip('.')
if y == sewerin_fcs:
fcs.append(os.path.join(dirpath, filename))
for fc in fcs:
fc_fields = []
important_fields = ['OBJECTID', 'SHAPE@LENGTH']
allfields = arcpy.ListFields(fc)
for field in allfields:
#print field.name
if field.name in important_fields:
print (field.name)
When the script finishes running, this is the printed result.
standalone script.
Jupyter Notebook script
It appears that the database in which these fields are sourced is the issue. When I checked all of the feature classes in the database that also have this field, the script wasn't working. I don't know if has something to do with field visibility or a setting within the database itself.
The script creates a detailed report of all the important feature classes within multiple databases within the default sde databases and compares those feature classes to the multiple databases within our production database. I am not sure how this issue can be resolved, but it is something that I don't quite know on how to trouble shoot.
I would greatly appreciate it if someone could assist me with this issue.
Sorry Dan, I must have misunderstood. In any case I finally realized where I was going wrong, and I was able to easily correct the issue.