Reputation: 2659
In R we can read a private google sheet given its URL simply with two lines of code.
library(googlesheets4)
manifest <- read_sheet(url)
The library googlesheets4 takes care of the authentication, where to store the information etc. and loads everything automatically into a table.
How can I do something similar with python?
import pandas as pd
import package as pck # Some package
pandas_dataframe = pck.read(sheetURL)
Is there a python package that does this? Ideally it would take care of authentication.
Upvotes: 3
Views: 254
Reputation: 5223
The most straightforward and optimized way to open spreadsheets in Python is to use the gspread
module as follows:
import gspread
gc = gspread.service_account()
sh = gc.open("SampleSheet")
print(sh.sheet1.get('Column1'))
However, you need to authenticate your Google account in order to access your own data sheets properly. So you can follow this documentation to set up a development environment that you can use to process data from Google into Python.
Also, you have the alternative to using Google Colab notebooks and easily access all of the data you have stored on Drive easily without much coding.
Upvotes: 5