I want to remove %
and replace with a string, and to remove space and replace it with under score.
This is what I have done so far:
# Open Excel file from a user imput
import xlrd, xlwt
filename = raw_input("Enter Excel file name with extension (.xls) and path")
oldbook = xlrd.open_workbook(filename)
newbook = xlwt.Workbook()
# For all the sheets in the workbook
for sheetname in oldbook.sheet_names():
oldsheet = oldbook.sheet_by_name(sheetname)
newsheet = newbook.add_sheet(sheetname)
# For all the rows and all the columns in an excel
for ii in range(oldsheet.nrows):
for jj in range(oldsheet.ncols):
# Replace
range.replace("%", "Perc")
# Save the file in a desired location with the desired name
savelocation = raw_input("Enter a new path and file name with extension (.xls) to save the new Excel spread sheet ")
newbook.save(savelocation)
One advice, read cell data into a string and then manipulate it.
Try this: (Unfortunately I cannot run it at the moment)