import arcpy import os arcpy.env.overwriteOutput = 1 arcpy.env.workspace = r"\\itdhq1apt50\GIS_Data\Test_MM\KellyRawCrash" for file in arcpy.ListFiles("*.xlsx"): outBase, outExt = os.path.splitext(file) outCrash = "Crash" + outBase print file print outCrash arcpy.TableToTable_conversion(file, gdb_loc, outCrash)
Solved! Go to Solution.
import arcpy, os arcpy.env.workspace = r"C:\GIS\xlsxTest" outPath = r"C:\GIS\xlsxTest\output" fileList = arcpy.ListFiles("*.xlsx") for file in fileList: arcpy.env.workspace = os.path.join(r"C:\GIS\xlsxTest", file) tabList = arcpy.ListTables() # Convert excel to DBF tabNum = 0 for tab in tabList: tabNum += 1 arcpy.TableToTable_conversion(tab, outPath, "Table"+tabNum+".dbf")
import arcpy, os arcpy.env.workspace = r"C:\GIS\xlsxTest" outPath = r"C:\GIS\xlsxTest\output" fileList = arcpy.ListFiles("*.xlsx") for file in fileList: arcpy.env.workspace = os.path.join(r"C:\GIS\xlsxTest", file) tabList = arcpy.ListTables() # Convert excel to DBF tabNum = 0 for tab in tabList: tabNum += 1 arcpy.TableToTable_conversion(tab, outPath, "Table"+tabNum+".dbf")
Here's an example of something close to what I do. Each sheet is it's own table.import arcpy, os arcpy.env.workspace = r"C:\GIS\xlsxTest" outPath = r"C:\GIS\xlsxTest\output" fileList = arcpy.ListFiles("*.xlsx") for file in fileList: arcpy.env.workspace = os.path.join(r"C:\GIS\xlsxTest", file) tabList = arcpy.ListTables() # Convert excel to DBF tabNum = 0 for tab in tabList: tabNum += 1 arcpy.TableToTable_conversion(tab, outPath, "Table"+tabNum+".dbf")