0

I'm trying to use FeatureClassToFeatureClass_conversion() to convert tab files to shapefiles. When I run the code below, the error says

C:/temp1\Overlays\Character_Places\Historic_Misc_Heritage.TAB Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset C:/temp1\Overlays\Character_Places\Historic_Misc_Heritage.TAB does not exist or is not supported. Failed to execute (FeatureClassToFeatureClass).

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"):
         tabFile = os.path.join(root, file)
         print(tabFile)

         outLocation = "C:/temp3/results.gdb"
         outFeatureClass = "shapefiles"
         arcpy.FeatureClassToFeatureClass_conversio(tabFile,outLocation, outFeatureClass)

When I comment out the FeatureClassToFeatureClass code and print(tabFile) tabFile's contents are printed as..

C:/temp1\Overlays\Character_Places\Historic_Misc_Heritage.TAB
C:/temp1\Overlays\Character_Places\Identified_Places_Heritage.TAB
C:/temp1\Overlays\Character_Places\places_of_history.TAB
C:/temp1\Overlays\Character_Places\places_of_culture.TAB
etc
etc

I'm unsure why its saying the dataset doesn't exist and why tabFile isn't the correct input parameter for FeatureClassToFeatureClass() to work

  • 1
    Can you please explain what the difference is between your previous question (gis.stackexchange.com/questions/210291/…) and this one? – fatih_dur Sep 12 '16 at 23:18
  • 1
    inFeatures = "tabFile" should be inFeatures = tabFile or just use tabFile instead of inFeatures further down. – PolyGeo Sep 12 '16 at 23:32
  • 1
    @TonyBonomo what was the result? Please update your question to reflect these changes – Midavalo Sep 12 '16 at 23:51
  • 1
    You need to know what kind of data you are outputting from your TAB file - you can't just export mydata.tab, you'd have to specify something like mydata.tab\mydata point to output a point shapefile from point data in your TAB file. – Midavalo Sep 13 '16 at 3:14
  • 1
    yes Im already using the Data interoperability ext in this. – Tony Bonomo Sep 13 '16 at 3:48
1

I'm not very familiar with TAB files, but when I view them in ArcCatalog they appear to be similar to a geodatabase which holds different feature classes with different geometries. When you reference a feature class in a geodatabase you construct a path like c:\mydata\mygeodatabase.gdb\myfeatureclass where you specify the feature class name after the geodatabase name.

It appears that you need to do something similar with the TABfile. My file looked like c:\mydata\mytabfile.tab\mytabfile point where you've got the name and geometry type after the tab filename.

enter image description here

When I try to run Feature Class to Feature Class on just the TAB file I get an error (same as yours from arcpy)

enter image description here

But when I include the actual geometry from inside the file, the tool accepts it and outputs it as expected

enter image description here

You may need to modify your script to something like this:

for root, dirs, files in os.walk(path,topdown=False):
   for file in files:
      if file.endswith(".TAB"):
         fc = os.path.splitext(file)[0]
         fcnamegeom = "{} point".format(fc)
         tabFile = os.path.join(root, file, fcnamegeom)
         print(tabFile)

         outLocation = "C:/temp3/results.gdb"
         outFeatureClass = fc
         arcpy.FeatureClassToFeatureClass_conversio(tabFile, outLocation, outFeatureClass)

This takes the name of the TAB file and removes the extension, and uses that as the feature class name and combines geometry type point to it (could be changed to whatever geometry type you're using). It then outputs the feature class to your geodatabase results.gdb using the feature class name as the output name.

There doesn't appear to be a way to get arcpy to automatically read the contents of the TAB file (using something like arcpy.ListFeatureClasses() or similar), so you may need to know what each one is beforehand - perhaps storing them in a gdb table and reading that to get the names and geometry type to pass through to your arcpy.FeatureClassToFeatureClass_conversion() tool.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.