-1

how would i pass a variable, so it's recognized as an attribute? the exact error i'm getting is,

AttributeError: 'Spreadsheet' object has no attribute 'row'

what i'm doing is writing data to google sheets using the gspread library

this code works,

wks = gc.open(row['sheet']).sheet1

but this code does not work,

wks = gc.open(row['sheet']).row['worksheet']

the difference is, there's no error if i hard code the worksheet value that i wish to write to sheet1, but if i pass sheet1 as a value into the variable, row['worksheet'] then i get the error

user3768071
  • 727
  • 5
  • 12
  • 17

1 Answers1

0

Let me write your code as

temp = gc.open(row['sheet'])
wks = temp.row['worksheet']

I think there's no variable named row in temp, that's why you are getting attribute error. just to check whether row exists as attribute of temp, use dir(temp) or vars(temp).

Hope, It'll help you.

Mangu Singh Rajpurohit
  • 10,806
  • 4
  • 68
  • 97