Knowledgebase: translator > Terminology
How to convert a MARTIF termbase to a bilingual glossary (TSV, CSV)
Posted by Peter Reynolds, Last modified by Viktor Mochnács on 26 March 2018 11:42 AM

To convert a MARTIF termbase to a bilingual glossary (TSV, CSV), you can:

Use Apsic Xbench (

Use the following Excel macro:

The following Excel macro will convert your MARTIF file to a simple two-column, source-target-language Excel glossary. While you will lose a lot of the more advanced information that might be contained in the MARTIF file (such as relationships between terms, synonyms, antonyms, definitions, etc.), sometimes, as you and I well know, it's the bare-bones glossary data that counts and that you will get.

And how to use the macro? Open the Macro dialog in Excel (earlier versions: Tools> Macro; current versions: select Macro on the View or Developer ribbon), enter mtf2xls, select Create, paste the macro and save it, run the macro, select the MARTIF file, convert, and voilà. You might run into problems with some broken special characters, but those should be an easy fix with a couple of quick search-and-replace actions.

Excel macro for converting martif to xls

Sub mtf2xls()

Dim fs, a, strs, rets, langs(10)
Flag = 0
strs = InputBox("path to martif")
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(strs, 1, -2)
j = 0
Do While f.AtEndOfStream <> True
rets = f.ReadLine
lgd = Len(rets)

If (Left(rets, 1) = " ") Then
lgk = lgd - 1
rets = Right(rets, lgk)
GoTo lab1
End If

If Left(rets, 10) = "<termEntry" Then
j = j + 1
Cells(j + 1, 1) = j
End If

wh = InStr(rets, "lang=")
If wh <> 0 Then
    wh = wh + 5
    asu = Asc(Mid(rets, wh, 1))
    we = wh
    we = we + 1
        If (Asc(Mid(rets, we, 1)) <> asu) Then
            GoTo recog2
        End If
    lantx = Mid(rets, wh + 1, we - wh - 1)

    If numlan = 0 Then GoTo addlan2
    For k = 1 To numlan
    If lantx = langs(k) Then GoTo knownlan2
    Next k
    numlan = numlan + 1
    k = numlan
    langs(k) = lantx
    Cells(1, k + 1) = lantx
End If

If Left(rets, 6) = "<term>" Then
    lgd = Len(rets)
    lgk = lgd - 13
    ttr = Mid(rets, 7, lgk)
    Cells(j + 1, k + 1) = ttr
End If

End Sub


(0 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Help Desk Software by Kayako