I'm trying to convert tab files to shape files. Issue is my code below converts only the last tab file in the os.walk list and not all the others. No python errors are reported and output prints the list of tab file paths below. Can anybody see something wrong as to why Quickimport converts one tab file and not the others?

import arcpy 
import os

path = "C:/temp1"
for root, dirs, files in os.walk(path,topdown=False):
    for file in files:
        if file.endswith(".TAB"):
            table = os.path.join(root, file)
            output = "C:/temp1/results.gdb"
            arcpy.QuickImport_interop(table, output)

enter image description here

  • I always prefer using arcpy.da.Walk() to os.walk() for traversing folders but in this case I think that code snippet should work for all three *.TAB files if it works for one. Using a picture, what do the contents of C:\temp1 look like in Windows Explorer? – PolyGeo Sep 6 '16 at 1:50
  • Hi Polygeo, please see a picture of my folders & files from my workspace. Each folder contains tab,dat,map and id files like above. My code will list all tab files but only convert the last tab file in folder 0V05_Flooding. – Tony Bonomo Sep 6 '16 at 3:39
  • I'm assuming that folder is a different one from C:\temp1 so what is output in your C:\temp1\Results.gdb and by the print statement when you run the code snippet you have presented with just the value of path` changed? – PolyGeo Sep 6 '16 at 3:46
  • In Windows explorer I can see results.gdb being updated in every iteration and its last modified time changes at every iteration too. When I open results.gdb in Arcmap to check, it just shows 1 converted tab file under it called Flooding.shp. – Tony Bonomo Sep 6 '16 at 4:13

I think the reason that you are only ever seeing one output feature class in that output file geodatabase is that, each time you run the Quick Import tool (which I do not recall ever having tried), the file geodatabase that you are writing to gets overwritten.

In the Using the Quick Import tool help it says:

A geodatabase is created containing the converted input data.

Each time that Quick Import runs in your loop it does not write the new feature class to the same file geodatabase as I think you are assuming. Instead it deletes that file geodatabase, creates a new one, and then writes the feature class into that new file geodatabase.

I prefer to use FeatureClassToFeatureClass rather than QuickImport for converting MapInfo TAB files to file geodatabase feature classes using the ArcGIS Data Interoperability extension. That tool copies feature classes into an existing file geodatabase; it does not create a new file geodatabase.

| improve this answer | |
  • Thank you for all your help today! Will try FeatureClassToFeatureClass. How can I mark this question as Answered please? – Tony Bonomo Sep 6 '16 at 4:53
  • No problem. There should be a tick mark next to it that you can click to turn it green. The meaning of this green tick is that this is the answer that helped you the most. If other answers are added later then you are free to transfer the green tick to one of them at any time that you decide a particular question actually helped you more. The tick does not mean an answer is right, just that it was either right or it at least helped you the most. Try to click it on one answer within a week or so of asking each question to keep encouraging people to try and answer them. – PolyGeo Sep 6 '16 at 4:58

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.