AnsweredAssumed Answered

Export multiple tables in GDB to Excel with a new sheet for each table

Question asked by brianmcleer on May 16, 2018
Latest reply on May 17, 2018 by brianmcleer

Researching to see if there is a way to use Python to export multiple tables in a File Geodatabase to a single Excel file. I would like for each sheet name to have the same name as the table.

 

My current situation is that I ran a Python script to take all the domains a GDB and create a table within the GDB. 

 

The article referenced from:

 

Batch export coded value domains to table 

 

def main(): 
import arcpy, os
gdb = r"Z:\GIS_Projects\zUpdatesBrian\Scripts\ListDomains\ListDomains.gdb"
arcpy.env.overwriteOutput = True

for dom in arcpy.da.ListDomains(gdb):
if dom.domainType == 'CodedValue':
arcpy.DomainToTable_management(in_workspace=gdb,
domain_name=dom.name,
out_table=os.path.join(gdb, dom.name),
code_field="item",
description_field="descrip",
configuration_keyword="")

print " - domain '{0}' of type '{1}' exported to table".format(dom.name, dom.domainType)
else:
print " - domain '{0}' of type '{1}' skipped".format(dom.name, dom.domainType)

if __name__ == '__main__':
main()

Outcomes