I have a link to a google spreadsheet that I do not own, but have view access to. Is there a way to get the data in that spreadsheet into the google colab notebook that I am using?
You should be able to retrieve the content of a Sheet with View Only access in gspread by using open_by_key()
or open_by_url()
.
Test Sheet:
Google Colab:
!pip install --upgrade -q gspread
import gspread
import pandas as pd
from google.colab import auth
from google.auth import default
auth.authenticate_user()
creds, _ = default()
gc = gspread.authorize(creds)
# sh = gc.open_by_url("Insert Sheet URL here")
sh = gc.open_by_key("Insert Sheet key here")
worksheet = sh.worksheet("Sheet1")
rows = worksheet.get_all_values()
pd.DataFrame.from_records(rows)
Result: