【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文件路径')

结果

相关推荐
Logic10136 分钟前
没有TextSplit函数的老版本也能拆分单元格的内容
excel·拆分数据·excel技巧·数据拆分·拆分单元格·textsplit·旧版excel
2601_967987372 小时前
你们都用Python实现了哪些自动化办公?
python·excel·自动化办公·1024程序员节·学习资料·跨平台操作
城数派2 小时前
1901-2025年中国省/市/县三级逐月平均气温数据Excel+Shp格式
excel
gtstore1 天前
从 Excel 迁移到仓库管理系统的数据准备与切换方案
excel·数据迁移·仓库管理系统·进销存·信息化实施
ms365copilot1 天前
我不再自己做 Word、Excel 和 PPT 了,我让 Copilot 直接帮我创建 (1)
word·powerpoint·excel·copilot
cspttty2 天前
2027采购岗求职:大数据管理与应用专业如何把Excel、SQL变成业务能力
excel
ms365copilot2 天前
Excel Copilot 一键定位修改的内容
excel·copilot
帆张芳显3 天前
前端表格公式能力新选择|智表 ZCell 公式引擎深度剖析
前端·excel·canva可画·excel插件
地图小课堂3 天前
Bigemap Pro 导入 Excel、CSV、TXT 点位表格教程
excel
我的愿望是成为富婆3 天前
2027校招准备:从Excel操作到数据分析,还缺业务、SQL与统计思维
sql·数据分析·excel