python配合googletrans翻译表格中的内容


#pip3 install googletrans==4.0.0rc1
from googletrans import Translator
import pandas as pd

translator = Translator()
translator.detect('hello')
tranlated = translator.translate('hello.', dest='zh-CN')

##translator.translate('veritas lux mea', src='la',dest='en')

src=r'AGO2 amplification is observed at low frequencies in a few tumor types, including breast cancer, sarcoma, and nerve sheath tumors (PMID: 28481359). Assuming the amplification of AGO2 is associated with elevated protein levels, limited data suggest that AGO2 amplification may be an oncogenic event. In one study, overexpression of AGO2 in human breast cancer cell lines mediated transformation (PMID: 18787018) and in another study of clinical specimens from patients with gastric cancer, AGO2 levels were elevated compared to normal tissue and correlated with HER2-negative disease and gender (PMID: 23775134). Knockdown of AGO2 protein in cancer cells resulted in reduced PI3K signaling and led to decreased cell proliferation and migration, arrested cell cycle and induced apoptosis (PMID: 28903378).'
tranlated = translator.translate(src, dest='zh-CN').text
print(tranlated)

df1=pd.read_excel(r'C:\Users\Administrator\Desktop\search\CNV数据库(1).xlsx',sheet_name='oncokb')
df2=pd.read_excel(r'C:\Users\Administrator\Desktop\search\CNV数据库(1).xlsx',sheet_name='ckb')

for i in range(len(df1)):
    if pd.isnull(df1.loc[i,'Interpretation']) == False:
        # list_all = main(df1.loc[i, 'Interpretation'])['translateResult'][0]
        # text_last=''
        # for j in list_all:
        #     text_add=j['tgt']
        #     text_last += text_add

        df1.loc[i,'chinese']=translator.translate(df1.loc[i,'Interpretation'], dest='zh-CN').text
    else:
        pass

new_wb=pd.ExcelWriter(r'C:\Users\Administrator\Desktop\search\CNV数据库_update1.xlsx')
df1.to_excel(new_wb,sheet_name='oncokb',index=None)
df2.to_excel(new_wb,sheet_name='ckb',index=None)


new_wb.close()
  • 9
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值