Closed s2t2 closed 1 year ago
Also, here is the (new) way to easily get user's credentials (colab only):
from google.colab import auth
# asks you to login
auth.authenticate_user()
from google.auth import default
# uses your login credentials
creds, _ = default()
print(creds)
NOTE IF YOU HAVE BARCODES / VALUES THAT START WITH ZERO (EDGE CASE)
OK so it looks like the read values function from gspread will numericise all values, so barcodes with leading zeros (like 012000161155
even with leading apostrophe '012000161155
) might not work unless we install the new version of gspread, and pass numericize_ignore
parameter
In colab:
%%capture
!pip uninstall gspread -y
!pip install gspread --upgrade
# !pip install gspread==5.5.0
# pass a list of ints of indices of the columns (starting at 1)
rows = sheet.get_all_records(numericise_ignore=[1])
Looks like there have been some changes to the gspread package API. https://gspread.readthedocs.io/en/latest/oauth2.html
We should make sure the existing notes still work, and update them as necessary.
UPDATE: new version of gspread with object oriented approach: https://github.com/prof-rossetti/flask-sheets-template-2023/blob/main/app/spreadsheet_service.py