0

AttributeError: 'str' object has no attribute 'A'

https://code.sololearn.com/cgmb7zFslwgT#py I'm trying to rapidly extract data from a spreadsheet, but keep getting errors I am using Visual Studio Code and I have run "pip install xlrd" https://code.sololearn.com/cgmb7zFslwgT#py from xlrd import open_workbook wb = open_workbook(r'C:\Users\steve\Google Drive\All\code\Book2.xlsx') values = [] for s in wb.sheets(): #print 'Sheet:',s.name for row in range(1, s.nrows): col_names = s.row(0) col_value = [] for name, col in zip(col_names, range(s.ncols)): value = (s.cell(row,col).value) try : value = str(int(value)) except : pass col_value.append((name.value, value)) values.append(col_value) (r'C:\Users\steve\Google Drive\All\code\Book2.xlsx'.A, 1) Error: Traceback (most recent call last): File "c:/Users/steve/Google Drive/All/code/Code/open Exel.py", line 15, in <module> values.append(col_value) (r'C:\Users\steve\Google Drive\All\code\Book2.xlsx'.A, 3) AttributeError: 'str' object has no attribute 'A'

26th Mar 2020, 6:56 PM
Steven
Steven - avatar
5 odpowiedzi
+ 3
Last line. You have some string... 'blabla' ..., and then you try to get its attribute A. 'blabla'.A Strings don't have that attribute. Just read the last line of any error message, it normally very explicitly tells you what's wrong: 'str' object has no attribute 'A'
26th Mar 2020, 7:43 PM
HonFu
HonFu - avatar
+ 1
Thanks for the help, everyone
27th Mar 2020, 1:32 AM
Steven
Steven - avatar
+ 1
Steven Ellet Your welcome.
27th Mar 2020, 1:35 AM
Denise Roßberg
Denise Roßberg - avatar
0
@HonFu I want to extract the information in specific cells, what am I doing wrong?
26th Mar 2020, 8:01 PM
Steven
Steven - avatar