Sunday 22 October 2017

arcpy - Using FeatureClassToFeatureClass_conversion to convert tab to shapefiles?


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 it tabFile rather than tablist because it is not a list.



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...