I am importing a bunch of data from excel using xlrd on python
I get all my data in string like this : text:u'L\xc9GENDE'
I manipulate these data and I try to put them back in excel (using xlsxwriter) and when I do, I get the same block of text text:u'L\xc9GENDE' instead of LÉGENDE.
What works for me :
#!/usr/bin/env python
# -*- coding: latin-1 -*-
import xlsxwriter
import sys
workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()
data = u'L\xc9GENDE'
worksheet.write('A1',data)
workbook.close()
this will work, I will get LÉGENDE in the A1 cell
but if I try to manipulate a string I have already to give me u'L\xc9GENDE', it will only show L\xc9GENDE in the A1 cell
---- EDIT ---- the code I use to retrieve data from excel
from xlrd import open_workbook
def grabexcelfile():
wb = open_workbook('leg.xls',encoding_override='latin-1')
log = []
txt = ''
for s in wb.sheets():
for row in range(s.nrows):
values = []
for col in range(s.ncols):
txt = str(s.cell(row,col))
txt.replace('-',' ',10)
log.append(txt)
return log
x = grabexcelfile()
print type(x[0]),x[0]
the print gives me : text:u'L\xc9GENDE'