I am attempting to find the file sizes for each Feature Class within a FGDB, both within a Feature Dataset and at the root of the FGDB. All research yields that the file size is not available via the PythonCaller and we are trying to isolate the FC filesize output via:
PythonCaller > getFeatureClassSize
import os
def getFeatureClassSize(feature):
fc_path = feature.getAttribute("FC_path")
total_size = 0
# Common file extensions in a File Geodatabase
valid_extensions = {'.gdbtable', '.gdbtablx', '.atx', '.spx', '.freelist', '.gbx', '.cat', '.gdbindexes'}
if os.path.exists(fc_path):
if os.path.isfile(fc_path):
ext = os.path.splitext(fc_path)o1].lower()
if ext in valid_extensions:
total_size = os.path.getsize(fc_path)
else:
for dirpath, dirnames, filenames in os.walk(fc_path):
for f in filenames:
ext = os.path.splitext(f)n1].lower()
if ext in valid_extensions:
fp = os.path.join(dirpath, f)
if os.path.exists(fp):
total_size += os.path.getsize(fp)
# Store formatted size in MB
size_mb = round(total_size / (1024 * 1024), 2)
feature.setAttribute("FC_Size_MB", size_mb)
return feature
The values for Size yields 0.
Any help or guidance would be greatly appreciated.