3

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?

3

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"
  • It's a pity, but the first loop won't work, because OGR can't update TAB files (even in the future... it's 2016 and this is a 2012 question). The second approach avoids this by using an update-able file format (SHP) for the merge, then converting the resultant SHP to a TAB. Yet another reason to never get your data in TAB format except if you can't avoid doing so. – GT. Feb 1 '17 at 3:44
2

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

0

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.

  • No real need for FME here IMO. Could be done with Mapbasic with a loop. – Nathan W Sep 26 '12 at 12:12
  • Fair enough, I'm not familiar with Mapbasic but recently performed a similar operation using FME, so I thought I'd share. – sgrieve Sep 26 '12 at 12:22
  • of course no problem at all. FME is a great tool. – Nathan W Sep 26 '12 at 13:28
0

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. Append2 Dialogue.

0

I have found that combiner-241.mbx works for folders of many tab files. append2.mbx doesn't handle large lists of tab files, freezes on adding. In my case combining over 16000 tab files full of buildingfootprint lidar points

0

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).

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.