Defining features in a list

M Whitman mgwhitman at gmail.com
Fri Sep 7 09:42:20 EDT 2012


Good Morning,

I have been recently trying to define all of the features in a list but have been running into errors.  I would like to define the features similar to the following print statement.  Any advice would be appreciated.  I'm trying to transition my output from a text file to excel and if I can loop through my lists and define them that transition will be cleaner.

Many Thanks,

-Matt

#Author: MGW
#2012 
import os, datetime, sys, arcpy, xlrd
from arcpy import env
submission = "Rev.mdb"
env.workspace = "C:/temp/"+submission+"/Water"

#Get Submission totals
fclist = sorted(arcpy.ListFeatureClasses("*"))
for fc in fclist:
    print fc+"="+str(arcpy.GetCount_management(fc).getOutput(0))

print "Complete"
raw_input("Press ENTER to close this window") 

Output Generated
WATER_Net_Junctions=312
WS_Hyd=484
WS_Mains=2752
WS_Node=4722
WS_Vlvs=1078
WS_WatLats=3661
WS_WatMtrs=3662
WTRPLANTS_points=0
WTRPUMPSTA_points=0
WTRTANKS=0
WTR_ARV=10
WTR_MISC=0
Complete
Press ENTER to close this window

#Get Submission totals
fclist = sorted(arcpy.ListFeatureClasses("*"))
for fc in fclist:
    fc=str(arcpy.GetCount_management(fc).getOutput(0))
    #TEST
    print WS_Hyd
   
        
print "Complete"
raw_input("Press ENTER to close this window") 

Output Generated
Traceback (most recent call last):
  File "C:\Documents and Settings\mattheww\Desktop\Copy of QAQCexce_2.py", line 14, in <module>
    print WS_Hyd
NameError: name 'WS_Hyd' is not defined



More information about the Python-list mailing list