How do I read .xls file into a long string with Python? -
how can use python read .xls file long string? have thousands of files , want replace '.' ',' within each of them.
yeah did; doesn't work.
hmmm, works me
import xlrd #for reading import xlwt #for writing def exceledit(path): #open book: wb = xlrd.open_workbook(path) #create new book book = xlwt.workbook(encoding="utf-8") #open sheet: in range(0, len(wb.sheet_names())): sh = wb.sheet_by_index(i) sh_name = wb.sheet_names()[i] print(sh_name) #create new sheet sheet = book.add_sheet(sh_name) #read row: k in range(0, sh.nrows): row = sh.row_values(k) #replace '.' ',' in cell j in range(0, len(row)): row[j] = str(row[j]).replace(".",",") # write row: sheet.write(k,j,row[j]) #save new book book.save(path[:-4] + "_edited.xls") exceledit('d:/files/myexcelfile.xls')
could give code?
Comments
Post a Comment