I am a Python newbie! I'm trying to list the feature classes in a dataset (Access .MDB) and then list the fields in each feature class.
I'm able to list the feature classes and I'm able to list the fields in a particular feature class if I name it specifically. For example, PARCEL is one of the feature classes listed in the dataset return. If I put "PARCEL" in the list fields criteria I get the field information for parcels. I would like to make it so that for each feature class returned it then lists the field information after it. I envisioned doing this with the list function, a loop (listing feature classes), and a sub-loop (listing fields from the feature classes. I feel like I'm close but that there is a small tweak that can be done or a more efficient way of going about this. I have listed the code below. Any help would be appreciated!
-Ty
## Import modules
import win32com.client , os.path, sys
gp = win32com.client .Dispatch("esri Geoprocessing.G pDispatch.1")
## Set workspace
gp.workspace = "C:\\Temp\\Zoni ng_Update_Final _060908.mdb"
#### List Datasets
dsList = gp.ListDatasets ("*", "all")
ds = dsList.Next()
while ds <> "":
print "DATASET:", ds
ds = dsList.Next()
## Set New workspace
gp.workspace = "C:\\Temp\\Zoni ng_Update_Final _060908.mdb\\La yers"
## List Featureclasses
fcList = gp.ListFeatureC lasses ("*", "all")
fc = fcList.Next()
while fc <> "":
print fc
fc = fcList.Next()
fList = gp.ListFields ("Parcel", "*", "all")
f = fList.Next()
while f <> None:
print "NAME:",f.N ame
print "TYPE:",f.T ype
print "LENGTH:",f.Len gth
print "PRECISION:",f. Precision
print "SCALE:",f.Scal e
print "NULL:",f.IsNul lable
print "DOMAIN:",f.Dom ain
f = fList.Next()
I'm able to list the feature classes and I'm able to list the fields in a particular feature class if I name it specifically. For example, PARCEL is one of the feature classes listed in the dataset return. If I put "PARCEL" in the list fields criteria I get the field information for parcels. I would like to make it so that for each feature class returned it then lists the field information after it. I envisioned doing this with the list function, a loop (listing feature classes), and a sub-loop (listing fields from the feature classes. I feel like I'm close but that there is a small tweak that can be done or a more efficient way of going about this. I have listed the code below. Any help would be appreciated!
-Ty
## Import modules
import win32com.client , os.path, sys
gp = win32com.client .Dispatch("esri Geoprocessing.G pDispatch.1")
## Set workspace
gp.workspace = "C:\\Temp\\Zoni ng_Update_Final _060908.mdb"
#### List Datasets
dsList = gp.ListDatasets ("*", "all")
ds = dsList.Next()
while ds <> "":
print "DATASET:", ds
ds = dsList.Next()
## Set New workspace
gp.workspace = "C:\\Temp\\Zoni ng_Update_Final _060908.mdb\\La yers"
## List Featureclasses
fcList = gp.ListFeatureC lasses ("*", "all")
fc = fcList.Next()
while fc <> "":
print fc
fc = fcList.Next()
fList = gp.ListFields ("Parcel", "*", "all")
f = fList.Next()
while f <> None:
print "NAME:",f.N ame
print "TYPE:",f.T ype
print "LENGTH:",f.Len gth
print "PRECISION:",f. Precision
print "SCALE:",f.Scal e
print "NULL:",f.IsNul lable
print "DOMAIN:",f.Dom ain
f = fList.Next()