Let me know if there is an easier way to assign values to variables from an existing document to use as output.
Traceback (most recent call last):
File "test.py", line 54, in <module>
row0.write(1, cellb)
File "/Library/Python/2.7/site-packages/xlwt/Row.py", line 259, in write
raise Exception("Unexpected data type %r" % type(label))
Exception: Unexpected data type <class 'xlrd.sheet.Cell'>
#imports
import xlrd
from xlrd import open_workbook, empty_cell
from tempfile import TemporaryFile
from xlwt import Workbook
#User input to decide what excel document
#print 'What excel file would you like to use to use?'
#excelfile = raw_input("'filename.xls' >> ")
#xlrd open and create book (name of book)
book = open_workbook('test.xls')
sheet = book.sheet_by_index(0)
#Set variables based on excel document
try:
cell1 = sheet.cell(0,0)
except:
cell1 = xlrd.empty_cell
try:
cell2 = sheet.cell(0,1)
except:
cell2 = xlrd.empty_cell
try:
cell3 = sheet.cell(0,2)
except:
cell3 = xlrd.empty_cell
try:
cell4 = sheet.cell(1,1)
except:
cell4 = xlrd.empty_cell
#Assign cell from above to parents value
cella = cell1
cellb = cell2
cellc = cell3
celld = cell4
#Output to excel document
book_w = Workbook()
sheet1 = book_w.add_sheet('Sheet 1')
#Column Headers
row0 = sheet1.row(0)
row0.write(0,'town')
row0.write(1, cellb) <-----ISSUE
#Sheet Name - Saved as date & time
book_w.save('output.xls')
book_w.save(TemporaryFile())
THANK YOU.