On 09/07/2012 09:42 AM, M Whitman wrote: > Good Morning, > > I have been recently trying to define all of the features in a list but have > been running into errors.
How proficient are you in Python? Could you possibly use terms which make sense to someone who doesn't know this arcGIS program? I'm just making a wild guess that that's what you're importing with the arcpy import. When I do an internet search on arcpy, I see lots of tutorials, training, etc. I didn't find a mailing list, but there probably is one. The term that needs translating is "feature.' > 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 > There's no variable WS_Hyd, so what did you expect it to do? Do you want to be able to fetch the values by name that were printed above? if so, I'd suggest a dict, not a list. Lists don't have names for each element, just indices. > > > 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 As a very rough start, perhaps you could try something like this. Remember i don't have the docs, so the only clue I've got is the stuff you printed from the first loop. table = {} fclist = sorted(arcpy.ListFeatureClasses("*")) for fc in fclist: table[fc] = +str(arcpy.GetCount_management(fc).getOutput(0)) Now, if you want to print the value for WS_Hyd, it should be available as print "value = ", table["WS_Hyd"] If you're sufficiently advanced, i could suggest a class-based solution where you'd access items by mytable.WS_Hyd But if you're not yet familiar with class definition and attributes and such, we'd better not go there. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list