Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. import xlrd
  2. import xlwt
  3.  
  4. workbook = xlrd.open_workbook(r"C:\Users\Elifritz_T\Desktop\Exceltest\2048.xls")
  5. workbook2 = xlrd.open_workbook(r"C:\Users\Elifritz_T\Desktop\Exceltest\Conservation_OwnedLand_Template.xlsx")
  6. sheet = workbook2.sheet_by_index(0)
  7. sheet2 = workbook2.sheet_by_index(1)
  8. #sheet3 = workbook2.sheet_by_index(2)
  9. #sheet4 = workbook2.sheet_by_index(3)
  10. #sheet5 = workbook2.sheet_by_index(4)
  11. #sheet6 = workbook2.sheet_by_index(5)
  12. #sheet7 = workbook2.sheet_by_index(6)
  13.  
  14. data = [sheet.cell_value(0, col) for col in range(sheet.ncols)]
  15. data2 = [sheet2.cell_value(0, col) for col in range(sheet2.ncols)]
  16. #data3 = [sheet3.cell_value(0, col) for col in range(sheet3.ncols)]
  17. #data4 = [sheet4.cell_value(0, col) for col in range(sheet4.ncols)]
  18. #data5 = [sheet5.cell_value(0, col) for col in range(sheet5.ncols)]
  19. #data6 = [sheet6.cell_value(0, col) for col in range(sheet6.ncols)]
  20. #data7 = [sheet7.cell_value(0, col) for col in range(sheet7.ncols)]
  21.  
  22. #rowdata = [sheet.cell_value(row, 0) for row in range(sheet.nrows)]
  23.  
  24. workbook = xlwt.Workbook()
  25. newsheet = workbook.add_sheet('test')
  26. newsheet2 = workbook.add_sheet('test2')
  27.  
  28. for index, value in enumerate(data):
  29. newsheet.write(0,index,value)
  30. newsheet2.write(0,index,value)
  31.  
  32.  
  33. workbook.save(r"C:\Users\Elifritz_T\Desktop\Exceltest\test4.xls")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement