Reputation: 33
I would like to translate the words which are stored in the excel file in column A
I have 2 parts (part 1 and Part 2 as stated below) of code, I do not know how to merge these both codes for successful translation for each word in to column B.
Looking for your help
Reading Excel file: code of part 1
import xlrd
# Give the location of the file
loc = (r"path\fruits.xlsx")
# To open Workbook
wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)
sheet.cell_value(0, 0)
for i in range(sheet.nrows):
print(sheet.cell_value(i, 0))
Translation : Code of Part 2
import goslate
text = "i am coming tomorrow"
gs = goslate.Goslate()
translatedText = gs.translate(text, 'de')
print(translatedText)
Upvotes: 0
Views: 537
Reputation: 87
import xlrd
import goslate
loc = r"C:\Users\kumarant\Desktop\Django\sahil\fruits.xlsx"
gs = goslate.Goslate()
wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)
for i in range(sheet.nrows):
print(gs.translate(sheet.cell_value(i, 0), 'de'))
Upvotes: 0