openpyxl - python : TypeError: 'str' object is not callable -


i've got simple, straight forward question - please @ code :

import openpyxl import warnings  warnings.simplefilter("ignore")  preq   = openpyxl.load_workbook('/users/ians/desktop/_complete.xlsx') preqwb = preq.get_sheet_names() preqas = preq.get_sheet_by_name(preqwb[0]) newrwa = open('/users/ians/desktop/newrwa.xlsx','w') in range(2, 101):     a=preqas['a'+str(i)].value <==== correct value printed     b=preqas['b'+str(i)].value <==== correct value printed     newrwa.write(a,b)   <=========== error line typeerror: 'str' object not callable  newrwa.close() 

try creating , saving output file using openpyxl library's inbuilt methods.

from openpyxl import workbook  newrwa = workbook() ws1 = newrwa.active in range(2,101):     = preqas['a'+str(i)].value     b = preqas['b'+str(i)].value     ws1.append([a, b])  newra.save(filename='/users/ians/desktop/newrwa.xlsx') 

Comments