Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import xlrd
- import xlwt
- workbook = xlrd.open_workbook(r"C:\Users\Elifritz_T\Desktop\Exceltest\2048.xls")
- workbook2 = xlrd.open_workbook(r"C:\Users\Elifritz_T\Desktop\Exceltest\Conservation_OwnedLand_Template.xlsx")
- sheet = workbook2.sheet_by_index(0)
- sheet2 = workbook2.sheet_by_index(1)
- #sheet3 = workbook2.sheet_by_index(2)
- #sheet4 = workbook2.sheet_by_index(3)
- #sheet5 = workbook2.sheet_by_index(4)
- #sheet6 = workbook2.sheet_by_index(5)
- #sheet7 = workbook2.sheet_by_index(6)
- data = [sheet.cell_value(0, col) for col in range(sheet.ncols)]
- data2 = [sheet2.cell_value(0, col) for col in range(sheet2.ncols)]
- #data3 = [sheet3.cell_value(0, col) for col in range(sheet3.ncols)]
- #data4 = [sheet4.cell_value(0, col) for col in range(sheet4.ncols)]
- #data5 = [sheet5.cell_value(0, col) for col in range(sheet5.ncols)]
- #data6 = [sheet6.cell_value(0, col) for col in range(sheet6.ncols)]
- #data7 = [sheet7.cell_value(0, col) for col in range(sheet7.ncols)]
- #rowdata = [sheet.cell_value(row, 0) for row in range(sheet.nrows)]
- workbook = xlwt.Workbook()
- newsheet = workbook.add_sheet('test')
- newsheet2 = workbook.add_sheet('test2')
- for index, value in enumerate(data):
- newsheet.write(0,index,value)
- newsheet2.write(0,index,value)
- workbook.save(r"C:\Users\Elifritz_T\Desktop\Exceltest\test4.xls")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement