I was wondering if there was a quick way to merge multiple .tab files together? I have about 100.
Would appending one tab to another with the MapBasic window open, then changing the name of the table appended to TableInfo(1,1) work?
If you don't want to use MapBasic (although there is really no reason you couldn't I just can't write the code off the top of my head) you can use OGR2OGR - a handy tool for any GIS pro to have in their toolkit.
There is a good start here http://gis-programming.com/?p=194 on the details of the code snippet below.
You can do something like this in a batch file:
for %f in (*.tab) do ( ogr2ogr -update -append merge.tab %f -f “MapInfo File” -nln merge )
Loop over all the TAB files in the current folder and append to the merge.tab file
Note: If the above doesn't work try this:
for %f in (*.tab) do ( ogr2ogr -update -append merge.shp %f -f “esri shapefile” -nln merge ) ogr2ogr merge.tab merge.shp -f "MapInfo File"
There are plente of tools available that can help you perform this task. Have a look at the site called MapInfoTools.com.
I think the tool Append2 could help you out
The best solution for this many files would probably be to use FME which is specifically designed to perform tasks like the one you have.
I just checked my copy and it supports .tab files and can output as a single merged .tab file, or a number of other formats, should that be more suitable. The software is not cheap, but a full 14 day trial is available for download from their website, which would be more than enough for you to run your conversions.
Append2 is the best option I have tried, provided you have all the TABs with similar "Table Structure". See the image. Select the check box "To New File" to get the appended/merged final TAB saved to a new file. This option is recommended.
I needed to create tab-extended files as my combined dataset was more than 2GB so I used the following. Make sure it is run in MI 64-bit. Thanks to previous questions asked here and answered.
//run mbx in folder with the .tab files //create a merged.tab file with the exact same structure as the files you are merging //Run the Dos Command //>>cmd.exe /c dir *.TAB /b /w > List.txt Include "MapBasic.def" Declare Sub Main Declare Sub ReadTextFileToArray(ByVal txtFilePath as String, myArray() as String) Sub Main() Dim myArray() as String '// create an array to store the table paths Dim tabName, tabPath, txtFile as String Dim i as Integer '// input text file generated using cmd txtFile = "List.txt" '// Open file to merge to Open Table "merged.tab" as merged '// create your list of paths text file... then: Call ReadTextFileToArray(txtFile, myArray) '// populate your array with the table paths from the text file For i = 1 to UBound(myArray) If right$(myArray(i), 3) = "TAB" then '// check that this is a tab file path tabPath = myArray(i) '// get path from array Open table tabPath '// open table tabName = TableInfo(0, TAB_INFO_NAME) '// Get Table name // Perform function Insert Into merged ( COL1, COL2, COL3, COL4) Select COL1, COL2, COL3, COL4 From tabName DropIndex Auto ' Pack table tabName Graphic Data '// pack table End if Next '// go to next element in array Commit Table merged Interactive End Sub Sub ReadTextFileToArray(ByVal txtFilePath as String, myArray() as String) Dim i as Integer i = 1 Open file txtFilePath for input as #1 '// open text file for input (to read) as #1 Do Until EOF(1) '// do until the end of file #1 is reached Redim myArray(i) '// resize array to i Input #1, myArray(i) '// read value from text file i = i + 1 '// increment i Loop '// return to Do Until... End Sub
It ended up creating 10.7GB files with no issues (except taking forever to load but works fine in Spectrum Spatial for tiles, which was the need).