Dear All, I am taking my initial steps to interact Python with excel files. I was success in importing the needed modules, and executing steps in interactive mode . All my initial commands such as import openpyxl wb = openpyxl.load_workbook('MyTutor.xlsx') wb.get_sheet_names() sheet= wb.get_sheet_by_name('SQL Results') sheet.title print sheet.title print sheet['A1']
All worked fine Now when I create a *.py file with all the above steps and run it, I am getting error Traceback (most recent call last): File "./ReadingDataFrom1X.py", line 10, in <module> c = sheet['A1'] TypeError: 'Worksheet' object has no attribute '__getitem__' The contents of “ReadingDataFrom1X.py” is as follows #!/usr/bin/python import openpyxl wb = openpyxl.load_workbook('MyTutor.xlsx') wb.get_sheet_names() sheet= wb.get_sheet_by_name('SQL Results') sheet.title print sheet.title print sheet['A1'] If the statement worked in the interactive mode, it should all work while executing the file created. Did some google search, did not come across any valid reason why the error message is showing. Would like to request for guidance and feed back, please let me know why all my command statements work on interactive mode and when I run it in a py file some commands throws error Thanks Joseph John _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor