import gspread
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("creds.json", scope)
client = gspread.authorize(creds)
sheet = client.open("doc_name").sheet1 # Open the spreadhseet
When i run this code i get the error:
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/gspread/client.py", line 120, in open properties = finditem( File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/gspread/utils.py", line 88, in finditem return next((item for item in seq if func(item)))
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/Users/samar/PycharmProjects/Automation/sheets.py", line 9, in sheet = client.open("Covid Data 2020-21").sheet1 # Open the spreadhseet File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/gspread/client.py", line 130, in open
raise SpreadsheetNotFound
gspread.exceptions.SpreadsheetNotFound