Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Python gp.ListFeatureClasses return only one file

25 views
Skip to first unread message

yoann06

unread,
Oct 13, 2011, 7:59:38 AM10/13/11
to
Hi All,
I m using the gp.ListFeatureClasses to make a list of file in my
directory (containing several hundreds of file)
however when I print the variable in which the List is supposed to be
stored, the print just return one file name....
does any one have an idea????

# Import system modules
import sys, string, os, arcgisscripting, glob, arcpy

# Create the Geoprocessor object
gp = arcgisscripting.create()
# define the workspace
gp.Workspace = r"F:\front\shp_Files\calving_front"
# list the file in the workspace

try:
shpList = gp.ListFeatureClasses("*.shp")
shp = shpList.Next()
print shp

except:
print arcpy.GetMessages() # allows to get error message when they
happen

Me

unread,
Oct 13, 2011, 11:05:01 PM10/13/11
to
Yoann,

you have to "consume" your list.
In pseudo code (sorry, I don't know Python):

'Get your list
list = getFileList()
'access the 1st (only) item
listItem = list.next()

'While there are some items left, process
while listItem
'Print its name (or do some real processing with it)
print listItem.name
'Access the next item
listItem = list.next
end while

0 new messages