Read time: 4 minutes

Read data from a Google Sheets spreadsheet using Python. Quickstart: https://developers.google.com/sheets/api/quickstart/python Go to the above URL and click on the “Enable the Google Sheets API” button which will look like the following image: 2018-07-16_00:11:28_728x163

$ python quickstart.py

Traceback (most recent call last): File "quickstart.py", line 22, in range=RANGE_NAME).execute()
File "/home/mandeep/envs/gapi/lib/python3.6/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper return wrapped(*args, **kwargs)
File "/home/mandeep/envs/gapi/lib/python3.6/site-packages/googleapiclient/http.py", line 842, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://sheets.googleapis.com/v4/spreadsheets/2BviMVs2XJA5pFNdKuBdBYagnWVqrtlos38OgvE2urmc/values/Class%20Data%21A2%3AE?alt=json
returned "Google Sheets API has not been used in project 9272345580241 before or it is disabled.
Enable it by visiting https://console.developers.google.com/apis/api/sheets.googleapis.com/overview?project=9272345580241 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.">

For example: Here is a sample spreadsheet: https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit#gid=0 Here “1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms” is the ID of this spreadsheet.

Traceback (most recent call last):
File "quickstart.py", line 15,
in if not creds or creds.invalid: File "/home/mandeep/envs/gapi/lib/python3.6/site-packages/googleapiclient/_helpers.py", line 130,
in positional_wrapper return wrapped(*args, **kwargs)

File "/home/mandeep/envs/gapi/lib/python3.6/site-packages/googleapiclient/http.py", line 842,
in execute

raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://sheets.googleapis.com/v4/spreadsheets/1Mhd1-CxxhnXv0VmxdDAWj4hSX1zhQAlVZuAfNXGnHak/values/Class%20Data%21A2%3AB?alt=json
returned "Unable to parse range: Class Data!A2:E">