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?
C:/temp\Boundary.TAB C:/temp\circle.TAB C:/temp\square.TAB etc,
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)
print(table)
output = "C:/temp1/results.gdb"
arcpy.QuickImport_interop(table, output)
1 Answer 1
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.
-
Thank you for all your help today! Will try FeatureClassToFeatureClass. How can I mark this question as Answered please?Tony Bonomo– Tony Bonomo2016年09月06日 04:53:49 +00:00Commented Sep 6, 2016 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.2016年09月06日 04:58:50 +00:00Commented Sep 6, 2016 at 4:58
*.TAB
files if it works for one. Using a picture, what do the contents ofC:\temp1
look like in Windows Explorer?C:\temp1
so what is output in yourC:\temp1\Results.gdb and by the print statement when you run the code snippet you have presented with just the value of
path` changed?