Python gp.ListFeatureClasses return only one file

Y

yo

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
 
A

Andreas Perstinger

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????

Depending on the version you are using, "ListFeatureClasses()" returns
either a list or an enumeration object:
http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=ListFeatureClasses_method

You are just printing the first item. To print all, something like the
following should work (assuming you are using version 9.2):

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

Bye, Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top