【SDL Trados Studio】sdltm格式转excel

思路

1.sdltm转tmx(SDL Trados Studio)

2.tmx转excel(代码/Xbench/Maxprograms/Localazy)

步骤

1.利用SDL Trados Studio打开sdltm文件

2.将选择要导出的翻译库,右键导出

3.查看tmx文件,发现tmx文件符合xml文件格式

4.利用python将tmx文件转为excel文件

代码

python 复制代码
import pandas as pd
import xml.etree.ElementTree as ET
def get_text_for_tag(root):
    texts = []
    for element in root.iter():
        if element.text:
            texts.append(element.text)
        if element.tail and element.tail != "\n      ":
            texts.append(element.tail)
    return ''.join(texts)
def tmx_to_excel(tmx_file, excel_file):
    tree = ET.parse(tmx_file)
    root = tree.getroot()
    # 初始化数据列表
    data = []
    # 遍历TMX文件中的每个tu(翻译单元)
    for tu in root.findall('.//tu'):
        seglist = tu.findall("tuv/seg")
        source_text = get_text_for_tag(seglist[0])
        target_text = get_text_for_tag(seglist[1])
        data.append([source_text, target_text])
    # 创建DataFrame
    df = pd.DataFrame(data, columns=['Source', 'Target'])
    # 导出为Excel文件
    df.to_excel(excel_file, index=False)
# 使用示例
tmx_to_excel(r'tmx文件路径', r'xlsx文件路径')

结果

相关推荐
夜流冰5 小时前
Excel - MS Support for Excel: 2 Collaborate
数据库·windows·excel
LingRannn13 小时前
【vim 中如何替换】
编辑器·vim·excel
yesyesido14 小时前
智能文件格式转换器:文本/Excel与CSV无缝互转的在线工具
开发语言·python·excel
开开心心_Every1 天前
免费进销存管理软件:云端本地双部署
java·游戏·微信·eclipse·pdf·excel·语音识别
Kasen's experience1 天前
Excel 怎么快速合并同一个ID不同行的大量相同单元格
excel
mudtools1 天前
基于.NET操作Excel COM组件生成数据透视报表
c#·.net·excel
yangminlei1 天前
Spring Boot+EasyExcel 实战:大数据量 Excel 导出(高效无 OOM)
spring boot·后端·excel
NignSah2 天前
Microsoft Excel World Championship 2025-2025EXCEL大赛,折纸
microsoft·excel
hhzz2 天前
Springboot项目中使用POI操作Excel(详细教程系列1/3)
spring boot·后端·excel·poi·easypoi
林月明2 天前
【VBA】点击一个按钮实现自动更新excel文件列数据
excel·vba·宏文件·一键数据更新