So i have several folders which each contain a gdb. Each gdb contains several tables with the name *_Table. I would like to iterate thru these folders/gdbs and output an Excel file for each *_Table at the same folder level as the gdb. So it should look like:
-folder --subfolder1 ---.gdb <--contains multiple tables ---Table1.xls ---Table2.xls ---etc. --subfolder2 ---.gdb <--contains multiple tables ---Table1.xls ---Table2.xls ---etc.
Now, I make the tables using the following code (probably could use some optimization): folder = arcpy.GetParameterAsText(0)
for dirpath, dirnames, filenames in arcpy.da.Walk(folder, datatype="FeatureClass",type="Polygon"): for filename in filenames: fc = os.path.join(dirpath, filename) table = dirpath + os.sep + filename + "_Table" result = arcpy.GetCount_management(fc) if int(result.getOutput(0)) > 0: print "Creating " + table arcpy.CopyRows_management(fc, table)
I would like to simply output the excel file at the same time, but i am unsure how to parse out the folder containing the .gdb to use as the path for the excel file.
How would I go about getting that parameter?
Aucun commentaire:
Enregistrer un commentaire