Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news0.firedrake.org!news.nosignal.org!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'importing': 0.04; 'output': 0.04; 'attributes': 0.07; 'sys,': 0.07; 'fetch': 0.09; 'loop.': 0.09; 'nameerror:': 0.09; 'proficient': 0.09; 'subject:features': 0.09; 'tutorials,': 0.09; 'cc:addr:python- list': 0.10; 'suggest': 0.11; '#test': 0.16; 'above?': 0.16; 'advanced,': 0.16; 'element,': 0.16; 'program?': 0.16; 'rough': 0.16; 'statement.': 0.16; 'such,': 0.16; 'xlrd': 0.16; 'wrote:': 0.17; 'skip:+ 40': 0.17; 'thanks,': 0.18; 'variable': 0.20; 'define': 0.20; 'python?': 0.20; 'skip:" 30': 0.20; 'trying': 0.21; 'import': 0.21; 'os,': 0.22; 'defined': 0.22; "i'd": 0.22; 'cc:2**0': 0.23; "i've": 0.23; 'cc:no real name:2**0': 0.24; "we'd": 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'values': 0.26; 'appreciated.': 0.26; '(most': 0.27; 'am,': 0.27; 'guess': 0.27; 'possibly': 0.27; 'errors.': 0.27; 'start,': 0.27; 'transition': 0.27; "doesn't": 0.28; 'there.': 0.28; 'subject:list': 0.28; 'definition': 0.29; 'probably': 0.29; 'class': 0.29; 'this.': 0.29; "i'm": 0.29; 'window': 0.30; 'stuff': 0.30; 'expect': 0.31; 'sense': 0.31; 'lists': 0.31; 'file': 0.32; 'running': 0.32; 'could': 0.32; 'print': 0.32; 'skip:s 30': 0.33; 'traceback': 0.33; 'excel': 0.33; 'text': 0.34; 'list': 0.35; 'so,': 0.35; 'table': 0.35; 'similar': 0.35; 'something': 0.35; 'there': 0.35; 'list.': 0.35; 'but': 0.36; "didn't": 0.36; 'should': 0.36; 'subject:: ': 0.38; 'advice': 0.39; 'received:192': 0.39; 'list,': 0.39; 'where': 0.40; 'skip:" 10': 0.40; 'received:192.168': 0.40; 'submission': 0.61; 'first': 0.61; 'training,': 0.62; 'close': 0.63; 'making': 0.64; 'header:Reply-To:1': 0.68; 'press': 0.71; 'internet': 0.71; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'dict,': 0.84; 'received:74.208.4.194': 0.84 Date: Fri, 07 Sep 2012 10:35:17 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: M Whitman Subject: Re: Defining features in a list References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:NsrF1vec+XAGTzED3KsC+I5fiOcQWoqgzyFLBaeAX5y WrbqFp7LVuaWgtZRs5QTxATRn/Mvs2wlL+sqHP2lrlb5NftX3m KNS3HQ0xXbnVoZGerbr2QYbLmVE6pIJekIV6sFBFrRIwCOjXhm LxnNmZbo+dKkg1tdvAbzSVUsMKUtJP7uOXijw0GmTzHouStZ0o bQonwPCEr1PuL3puUPZTRQdxMKeKUzLbyj7HlRPzQHON2J7gu+ EhtGqrYQYeAlnQpKhadHcP9KIPCD7GaxYFwuWcjpT4pJK9ODjp Xwgdn+PZ2rYeCz4L8SnIUbAoC384Jq26Z45uPLk2cuSfrXtqQ= = Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 99 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347028546 news.xs4all.nl 6895 [2001:888:2000:d::a6]:36736 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28691 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 > 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