My code:
import gspread
from gspread import worksheet
from oauth2client.service_account import ServiceAccountCredentials
scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name("keys.json", scope)
client = gspread.authorize(creds)
spreadsheet = client.open("ackerwaldundwiese")
worksheet.update_cell(1, 2, "car")
Output
Traceback (most recent call last):
File "C:\Users\mm\PycharmProjects\pythonProject1\ddf.py", line 8, in <module>
worksheet.update_cell(1, 2, "car")
AttributeError: module 'gspread.worksheet' has no attribute 'update_cell'
I'm using PyCharm 2022.1.1 (Community Edition) windows 10
Hi before accessing a worksheet you must retrieve it first.
In you situation it should be sometlike this:
spreadsheet = client.open("ackerwaldundwiese")
worksheet = spreadsheet.sheet1
worksheet.update_cell(1, 2, "car")
Note: this will return the first sheet, if you need to get a different sheet use the method get_worksheet
You should remove this line from your code:
from gspread import worksheet
You don't need to import the Worksheet
object and it is case sensitive so the worksheet object does not exists but the Worksheet does.