How to use Google Sheets API in Python

Learn how to use Google Sheets API in Python. We are using the gspread module for this. It’s super simple to setup a project, and then access and modify our spreadsheet with a Python script. Google Sheets can be pretty powerful and used as a backend to store some data for your web applications.

The code can be found here:


What is GEEK

Buddha Community

How to use Google Sheets API in Python
Ray  Patel

Ray Patel


top 30 Python Tips and Tricks for Beginners

Welcome to my Blog , In this article, you are going to learn the top 10 python tips and tricks.

1) swap two numbers.

2) Reversing a string in Python.

3) Create a single string from all the elements in list.

4) Chaining Of Comparison Operators.

5) Print The File Path Of Imported Modules.

6) Return Multiple Values From Functions.

7) Find The Most Frequent Value In A List.

8) Check The Memory Usage Of An Object.

#python #python hacks tricks #python learning tips #python programming tricks #python tips #python tips and tricks #python tips and tricks advanced #python tips and tricks for beginners #python tips tricks and techniques #python tutorial #tips and tricks in python #tips to learn python #top 30 python tips and tricks for beginners

Ray  Patel

Ray Patel


Lambda, Map, Filter functions in python

Welcome to my Blog, In this article, we will learn python lambda function, Map function, and filter function.

Lambda function in python: Lambda is a one line anonymous function and lambda takes any number of arguments but can only have one expression and python lambda syntax is

Syntax: x = lambda arguments : expression

Now i will show you some python lambda function examples:

#python #anonymous function python #filter function in python #lambda #lambda python 3 #map python #python filter #python filter lambda #python lambda #python lambda examples #python map

Art  Lind

Art Lind


Get Google Trends using Python

In this post, we will show how we can use Python to get data from Google Trends. Let’s have a look at the top trending searches for today in the US (14th of March, 2020). As we can see, the top search is about Coronavirus tips with more than 2M searches, and at the 7th position is Rick Pitino with around 100K searches.

Image for post

Python package for getting the Google Trends

We will use the pytrends package which is an unofficial API for Google Trends which allows a simple interface for automating downloading of reports from Google Trends. The main feature is to allow the script to login to Google on your behalf to enable a higher rate limit. At this point, I want to mention that I couldn’t use this package and I created a new anaconda environment installing the pandas 0.25 version.

You can install the pytrends package with pip:

pip install pytrends

#google-trends #how-to-use-google-trend #google #google-api #python

Kaustav Hazra


Google Sheets API using Python 

In this article we will discuss how to access and edit Google Sheets using Python.

Accessing data from multiple sources using Python becomes a standard requirement for nearly any position in data science and analytics. Working with Excel spreadsheets and internal CSV files happens everywhere.

But what if your data is now stored on Google Drive as a Google Sheet? Of course you can download it in any format of your choice. Yet it is not a scalable solution since it requires constant human input.

Let’s see how we can solve this in a programmatic way and even automate some of the tasks when working with Google Sheets using Python.

#api #python #python-programming #google-sheets

Marcelle  Smith

Marcelle Smith


Google Sheets, Meet Pandas DataFrame

Maybe it’s from too many hours behind the keyboard. But sometimes my reading and watching on the internet gives me the feeling I’m one of an endangered species of developer. One who’s working inside spreadsheets. Every single day.

Can you believe it? Developers, going about their lives like spreadsheets don’t exist. If you are one of these people, I’d like to meet you. To know that you exist, and this isn’t all a paranoid rant raging between my ears.

For the rest of us, spreadsheets are very much a thing. Love them or hate them, those binary rows and columns are going nowhere. To cut the philosophy lesson short: spreadsheets are. Every non-developer employee save the cleaning staff lives inside spreadsheets.

“Spreadsheets are.” Submit this existential bombshell to a university; an honorary doctorate in philosophy is sure to follow.

Excel and Google Sheets, they’re going nowhere; neither is our productivity until we put automation between us and the knowledge worker ritual of passing the spreadsheet.

My Two Cents in Three Paragraphs

Personally, I love a good spreadsheet. For munging data, quick and dirty calculations, visualizing 1-dimensional times series… 4 out of 5 times I will open Excel or Google Sheets, rather than fire up a Jupyter server.

Except, spreadsheetitis in a business is a symptom of not knowing how to move data. I have personally seen the “human router” problem so bad where more than 20 (twenty!) people touched a version of a spreadsheet before it was finally–mercifully–put to rest in “the database” (another spreadsheet).

And THE Spreadsheet. You know the business is in data hell when there’s The Spreadsheet, with a capital “S”. The one managers think is the business.

Automate Your Way to Sanity

There’s a few libraries we will talk about using for Google Sheets I/O in Python. No matter the approach, you have to enable the Google Sheets API inside the maze-like console for Google Cloud Platform (Google’s version of AWS and Azure). Fortunately Google–go figure–has a great search feature in the console that we’ll use to get you set up.

Insanity First — Getting a credentials.json file from Google Cloud Platform

Go to, sign in with the Google account with access to the spreadsheet you want to automate. The API is available for both GSuite and free Google accounts. If it’s a work-owned spreadsheet, the admin with GCP access is going to have to follow these steps and give you the credentials file.

Select the project in the navbar on the top. Every resource is kept inside a project, like resource groups in Azure. If you do not have one yet, select the project dropdown and “NEW PROJECT”. Then search for “Google Sheets API”, which if you are a sadist and want to explore the dashboard by mouse, is under “APIs & Services”.

Image for post

“Enable” the API.

Now you need to do the same for Google Drive API.

Image for post

Next up, you need to create a service account, which you will then create credentials for.


  • You are in Google Cloud Platform > Google Sheets API at
  • Go to credentials 🗝 Credentials on the sidebar.
  • Select + CREATE CREDENTIALS > Service Account. OAuth is a different story. This article covers a server-side, in-house use. Create the service account.
  • Next view is to select an IAM role for the service account. This is optional, skip it.
  • Next up is “Grant users access to this service account (optional)”. Also skip.

Image for post

Image for post

Now you are back on the “Service accounts for project [PROJECT NAME]” screen. Select the service account in the table, either clicking on the hyperlinked Email field, or hamburger menu (three dots) > Create key.

Either way, ADD KEY or Create key, select JSON key type and CREATE. This downloads a JSON file to your computer.

Image for post

Last thing: the spreadsheet. Here I created one for this example. Note the highlighted section of the URL in the Omnibar. That is the document’s ID. Most libraries give the choice of referencing the whole URL or just this ID.

Image for post

You can take a look at and download the spreadsheet from here.

Open the credentials.json file you downloaded from GCP for the service account. Copy the email value in the client_email property. Share the Google Sheet with this email. This gives the service account access to the spreadsheet, which was created on another account (not the service account).

Phew. That’s all the Google infrastructure stuff. I promise.

Now we can get down to business writing Python code.

#google-sheets #python-programming #python-libraries #google-drive-api #google-cloud-platform #api