I am getting an error:
Traceback (most recent call last):
File "clubranking.py", line 14, in <module>
ws_out = wb_out.add_sheet(sheet_name)
TypeError: unbound method add_sheet() must be called with Workbook instance as first argument (got unicode instance instead)
When trying to run this python script:
#import the writer
import xlwt
#import the reader
import xlrd
#open document
wb_in = xlrd.open_workbook('sussex.xlsx')
#get first sheet's name from the document
sheet_name = wb_in.sheet_names()[0]
#select sheet by name
ws_in = wb_in.sheet_by_name(sheet_name)
#init xlwt object, to be able to write data
wb_out = xlwt.Workbook
#initialise first sheet from the previously opened document, for
writing
ws_out = wb_out.add_sheet(sheet_name)
#print the values in the second column of the first sheet
print first_sheet.col_values(1)
book = xlwt.Workbook('sussex.xlsx')
#in cell 0,0 (first cell of the first row) write "NIF"
first_sheet.write(0, 6, "NIF")
#in cell 0,0 (first cell of the first row) write "Points scored"
first_sheet.write(0, 6, "Points scored")
I'm not sure what the issue is as I'm a beginner in this realm but any help would be greatly appreciated. What I am trying to achieve is outlined is this other question that I wrote: How to get Python script to write to existing sheet
You are missing opening a workbook here.
wb_out = xlwt.Workbook
which should be like:
wb_out = xlwt.Workbook()
Open your workbook properly and problem should be fixed.