from openpyxl import load_workbook,workbook book = load_workbook('myfile.xlsx') sheet = book.get_active_sheet() r in sheet.rows: cell in r: firstname = cell.value(row=r, column='1') lastname = cell.value(row=r, column='2') print firstname, lastname
i want assign each cell value on current row seperate variable. when try above code error:
typeerror: 'unicode' object not callable
any appreciated, thanks.
ok i've figured out failed here, embarassed admit it!
when checked values trying feed openpyxl error clear, "r" variable string full of data rather integer. using simple "rowcount" like..
rowcount = 0 r in ws.rows: firstname = ws.cell(row = rowcount, column = 0) lastname = ws.cell(row = rowcount, column = 1) rowcount = rowcount + 1 print firstname.value, lastname.value
seems have done trick.
Comments
Post a Comment