-
Notifications
You must be signed in to change notification settings - Fork 1
02‐GoogleSheet Preparation
Teeraphat Kullanankanjana edited this page Oct 28, 2023
·
2 revisions
- Google Sheet URL.
- Google Sheet Page Name (not the name of file inside the Google Drive).
- Google App Script Deployment ID.
- Create your Google Sheet https://docs.google.com/spreadsheets.
- Copy the full URL of your sheet (for example: https://docs.google.com/spreadsheets/d/your_google_sheet_id/edit#gid=0).
- Copy the name of your page sheet (the default is
Sheet1
).
- At the
Extensions
menu, select theApps Script
, and then the new Google Apps Script should be created. - In the Google Apps Script window, copy all of the script from
script.gs
and paste them into Google Apps Script. - Save the script.
- Click the
Deploy
button, then selectNew Deployment
. After that, the new deployment window should appear. - On the select type menu on the left-side of the window, select
Web app
. - On the configuration menu on the right-side of the window, make sure the scripts are executed by
Me (Your Email)
and who has access is set toAnyone
. - Click
Deploy
. - Then authorize the aceess with your email (the same email as the owner of google sheet)
- If the window shows
Google hasn’t verified this app
, select theAdvanced
menu and click Go to<your script name> (unsafe)
. and continue to authorize the access. - After that, the window will show the
Deployment ID
. - Copy it.
After importing your class, create a class instance and put all three credentials into your code.
And don't forget to connect the internet network; otherwise, the code will not work.
# Import Library
from ggsheet import MicroGoogleSheet
from network import WLAN,STA_IF
# Network Creadential
ssid = "Change_SSID"
password = "Change_Password"
# Connect to Network
sta_if = WLAN(STA_IF)
sta_if.active(True)
if not sta_if.isconnected():
print("Connecting to wifi: ", ssid)
sta_if.connect(ssid, password)
while not sta_if.isconnected():
pass
print("Connection successful")
# Google Sheet Credential
google_sheet_url = "https://docs.google.com/spreadsheets/d/xxxxxxxxx/edit#gid=0"
google_sheet_name = "Sheet1"
google_app_deployment_id = "xxxxxxxx"
# Create Instance
ggsheet = MicroGoogleSheet(google_sheet_url,google_sheet_name)
ggsheet.set_DeploymentID(google_app_deployment_id)