[英]Excel sheet translation using python
I have an excel sheet filled with English text, so now I wanted to convert each text to other languages (example:- french) and insert in the next column of the excel sheet using python.我有一张 excel 表,里面填满了英文文本,所以现在我想将每个文本转换为其他语言(例如:- 法语)并使用 Z23EEEB4347BDD26BFC6B7EE9A3B75DD 插入 excel 表的下一列
So how to approach this?那么如何处理呢?
I'm currently going through pandas of python.我目前正在通过 python 的 pandas 。
This should work.这应该有效。 Make sure you pip install googletrans-temp
确保你pip install googletrans-temp
import pandas as pd
from googletrans import Translator
# read from an excel file
df = pd.read_excel('/Users/andrewgreatorex/Downloads/test_spreadsheet.xlsx')
# translate a column to French, and add back into the DataFrame
translator = Translator()
df['French'] = df['text'].apply(translator.translate,src='en',dest='fr').apply(getattr, args=('text',))
# output new excel file
df.to_excel('name_of_your_output_file.xlsx')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.