I'm trying to use FeatureClassToFeatureClass_conversion() to convert tab files to shapefiles. When I run the code below (no errors reported) it prints the list of all tab files in the workspace like this.
C:/temp1\circle.tab
C:/temp1\square.tab
C:/temp1\triangle.tab
import arcpy
from arcpy import env
import os
path = "C:/temp1"
for root, dirs, files in os.walk(path,topdown=False):
for file in files:
if file.endswith(".TAB"):
tablist = os.path.join(root, file)
print(tablist)
**#Unsure what to put here next to add the tab files above into a feature class/layer**
Since FeatureClassToFeatureClass_conversion() requires an input feature class or layer, how can I add the list of tab files above into a feature class/layer so FeatureClassToFeatureClass_conversion() can run?
Answer
As long as you have a Data Interoperability license available you should be able to use something like:
arcpy.FeatureClassToFeatureClass_conversion(
tablist,inputFileGDB,fcName)
inputFileGDB
is the file geodatabase you want the feature classes to be created in.fcName
is the name of the feature class to be created.tablist
is the name of the TAB file, although for readability I would name ittabFile
rather thantablist
because it is not a list.
No comments:
Post a Comment