Access Google Sheet by Python

Andrew Chien
3 min readMay 6, 2020

--

Step 1: Go to Google API Console

Step 2: Add New Project

Click the inverted triangle on the top bar and then create the new project.

Click the inverted triangle
ddddd
Click NEW PROJECT
Input Project name

Step 3: Search Google Sheet API

Search Google Sheet API
Enable Google Sheet API

Step 4: After creating the Google Sheet API, choose the Credentials from the left bar and then click CREATE CREDENTIALS and finally choose Service account

Create Service account

Step 5: Create Service Account

Input service account name and then Click CREATE
Choose Role Owner
Create Key
Choose Key Type in JSON

Step 6: After creating the JSON type key, then it will automatically download it to the local. Next action is to open the JSON file, and then find the key “client_email” and copy that value. Afterward, go to the google sheet you want to work via API and share the sheet with the value(mail) you copied from the JSON file.

Step 7: Run the code

For the “allwks_key” in the code snippet, it’s from the google sheet url link. For example, https://docs.google.com/spreadsheets/d/ xxxxx/edit#gid=ooo ,then xxxxx is the key.

The above is the step by step of getting the Google sheet value via Google Sheet API. If there is anything unclear or this article can improve, don’t hesitate to leave the message. :)

--

--

No responses yet