Package: gsheetsplus
gsheetsplusgsheetsplusis an extension over thegsheetslibrary to provide added functionalities like plotting graphs between two axis.Turn on the API, download an OAuth client ID as JSON file, and create aSheetsobject from it. Use its index access (__getitem__) to retrieve
SpreadSheet objects by their id, or use.get()with a sheet URL.
Iterate over theSheetsobject for all spreadsheets, or fetch spreadsheets
by title with the.find()and.findall()methods.SpreadSheet objects are collections of WorkSheets, which provide access to the
cell values via spreadsheet coordinates/slices (e.g.ws['A1']) and
zero-based cell position (e.g.ws.at(0, 1)).LinksGitHub:https://github.com/tanmaypandey7/gsheetsplusPyPI:https://pypi.org/project/gsheetsplus/Download:https://pypi.org/project/gsheetsplus/#filesInstallationThis package runs under 3.8+, use pip to install:pip install gsheetsplusThis will also install gsheets, matplotlib and their dependencies.QuickstartLog into theGoogle Developers Consolewith the Google account whose
spreadsheets you want to access. Create (or select) a project and enable theDrive APIandSheets API(underGoogle Apps APIs).Go to theCredentialsfor your project and createNew credentials>OAuth client ID> of typeOther. In the list of yourOAuth 2.0 client
IDsclickDownload JSONfor the Client ID you just created. Save the
file asclient_secrets.jsonin your home directory (user directory).
Another file, namedstorage.jsonin this example, will be created after
successful authorization to cache OAuth data.On you first usage ofgsheetswith this file (holding the client secrets),
your webbrowser will be opened, asking you to log in with your Google account
to authorize this client read access to all its Google Drive files and Google
Sheets.Create a sheets object:>>>fromgsheetsimportSheets>>>sheets=Sheets.from_files('~/client_secrets.json','~/storage.json')>>>sheets#doctest: +ELLIPSIS<gsheets.api.Sheetsobjectat0x...>Fetch a spreadsheet by id or url:# id only>>>sheet['1dR13B3Wi_KJGUJQ0BZa2frLAVxhZnbz0hpwCcWSvb20']<SpreadSheet1dR13...20u'Spam'># id or url>>>url='https://docs.google.com/spreadsheets/d/1dR13B3Wi_KJGUJQ0BZa2frLAVxhZnbz0hpwCcWSvb20'>>>s=sheets.get(url)>>>s<SpreadSheet1dR13...20u'Spam'>Access worksheets and their values:# first worksheet with title>>>s.find('Tabellenblatt2')<WorkSheet1747240182u'Tabellenblatt2'(10x2)># worksheet by position, cell value by index>>>s.sheets[0]['A1']u'spam'# worksheet by id, cell value by position>>>s[1747240182].at(row=1,col=1)1Dump a worksheet to a CSV file:>>>s.sheets[1].to_csv('Spam.csv',encoding='utf-8',dialect='excel')Dump all worksheet to a CSV file (deriving filenames from spreadsheet and
worksheet title):>>>csv_name=lambdainfos:'%(title)s-%(sheet)s.csv'%infos>>>s.to_csv(make_filename=csv_name)Load the worksheet data into a pandas DataFrame (requirespandas):>>>s.find('Tabellenblatt2').to_frame(index_col='spam')eggsspamspameggs...WorkSheet.to_frame()passes its kwargs on topandas.read_csv()Plot graph between two axis(requirespandas):>>>df=s.find("Sheet1").to_frame()>>>sheets.plot(df,"offer_price","average_sales","graph")>>>plt.show()Detailed documentation for Gsheets can be foundhere.See alsogsheetsBase library for gsheetsplusgsheets.pyself-containd script to dump all worksheets of a Google
Spreadsheet to CSV or convert any subsheet to a pandas DataFrame (Python 2
prototype for this library)gspreadGoogle Spreadsheets Python API (more mature and featureful
Python wrapper, currently using the XML-basedlegacy v3 API)example Jupyter notebookusinggspreadto fetch a sheet into a pandas
DataFramedf2gspreadTransfer data between Google Spreadsheets and Pandas (build
upongspread, currently Python 2 only, GPL)pygsheetsGoogle Spreadsheets Python API v4 (v4 port ofgspreadproviding further extensions)gspread-pandasInteract with Google Spreadsheet through Pandas DataFramespgsheetsManipulate Google Sheets Using Pandas DataFrames (independent
bidirectional transfer library, using thelegacy v3 API, Python 3 only)PyDriveGoogle Drive API made easy (google-api-python-clientwrapper
for theGoogle DriveAPI, currently v2)LicenseThis package is distributed under theMIT license.