Autodrive is designed to make it as easy as possible to interact with the Google Drive and Sheets APIs via Python

Overview

Autodrive

Autodrive is designed to make it as easy as possible to interact with the Google Drive and Sheets APIs via Python. It is especially designed to provide as much assistance as possible when writing code through hints and autocompletion, as well as via thorough type checking and hinting. These features are currently optimized for VSCode, which you can download here if you wish. They should also work in other Python IDEs.


Documentation: https://autodrive-py.readthedocs.io/en/latest/


Requirements


Python 3.8+

Installation


Google API Credentials

Follow the steps outlined in the Prerequisites section here. Download and save the credentials.json file to the working directory you want to use Autodrive in.

First Connection

To test that your credentials provide the expected connection to your Google Drive account, simply instantiate an Autodrive Drive instance:

from autodrive import Drive

drive = Drive()

If your credentials file was saved as credentials.json, your browser should automatically open and prompt you to authorize the GCP project you created to access your Google Drive. Click the various Allow prompts it will show you to complete your first connection. After you see the browser switch to a page indicating you can close the process, you should see a gdrive_token.json file added to the working directory you saved your credentials.json file in. Next time you use an Autodrive element that needs to connect to your Drive, this token will be used and you will not be prompted to authorize access again until it expires.

Quickstart


The Drive class provides methods for finding and creating objects in your Google Drive, such as Folders or Sheets.

gsheet = drive.create_gsheet("my-autodrive-gsheet")

Finding IDs

If you use Drive to search for your Sheets and Folders, you don't need to supply the GSheet or Folder IDs yourself, but if you know exactly what Sheet you want, then you can directly instantiate a GSheet or folder by pulling the necessary info from the object's url.

For example, if your Sheet's url looks like this:

docs.google.com/spreadsheets/d/19k5cT9Klw1CA8Sum-olP7C0JUo6_kMiOAKDEeHPiSr8/edit#gid=0

Simply copy/paste the id between /d/ and /edit# as the gsheet_id:

from autodrive import GSheet

gsheet = GSheet(gsheet_id="19k5cT9Klw1CA8Sum-olP7C0JUo6_kMiOAKDEeHPiSr8")

Tabs: Because Google calls spreadsheets "Sheets", and their api also refers to the individual sub-sheets in a spreadsheet as "Sheets", Autodrive instead refers to them as "Tabs" for clarity.

For a tab, you can get the tab_id from:

docs.google.com/spreadsheets/d/19k5cT9Klw1CA8Sum-olP7C0JUo6_kMiOAKDEeHPiSr8/edit#gid=234276686

from autodrive import Tab

tab = Tab(
    gsheet_id="19k5cT9Klw1CA8Sum-olP7C0JUo6_kMiOAKDEeHPiSr8",
    tab_title="Sheet2",
    tab_idx=0,
    tab_id=234276686
)

For a folder:

drive.google.com/drive/u/1/folders/1wLx-KMG2jO498xa5ZumB-SEpL-TwczZI

from autodrive import Folder

folder = Folder(folder_id="1wLx-KMG2jO498xa5ZumB-SEpL-TwczZI", name="Test Folder")

Reading and Writing

You can easily download and write data from a Google Sheet using the GSheet, Tab, or Range views.

# Fetches all the data in all cells of the tab:
tab.get_data()

# Writes 8 cells (2 rows of 4 columns, starting in cell A1) to the tab:
tab.write_values(
    [
        [1, 2, 3, 4],
        [5, 6, 7, 8],
    ]
)

GSheet and Range have very similar methods, and all of them allow you to read and write data to only a specific range in the Google Sheet. See the Documentation for more.

You might also like...
Interact and easily use Google Chat room webhooks.

Chat Webhooks Easily interact and send messages with Google Chat's webhooks feature. This API is small, but should be a nice framework for working wit

First Party data integration solution built for marketing teams to enable audience and conversion onboarding into Google Marketing products (Google Ads, Campaign Manager, Google Analytics).

Megalista Sample integration code for onboarding offline/CRM data from BigQuery as custom audiences or offline conversions in Google Ads, Google Analy

Deepak Clouds Torrent is a multipurpose Telegram Bot writen in Python for mirroring files on the Internet to our beloved Google Drive.
Deepak Clouds Torrent is a multipurpose Telegram Bot writen in Python for mirroring files on the Internet to our beloved Google Drive.

Deepak Clouds Torrent is a multipurpose Telegram Bot writen in Python for mirroring files on the Internet to our beloved Google Drive.

A python based all-in-one tool for Google Drive

gdrive-tools A python based all-in-one tool for Google Drive Uses For Gdrive-Tools ✓ generate SA ✓ Add the SA and Add them to TD automatically ✓ Gener

This Mirror Bot is a multipurpose Telegram Bot writen in Python for mirroring files on the Internet to our beloved Google Drive.
This Mirror Bot is a multipurpose Telegram Bot writen in Python for mirroring files on the Internet to our beloved Google Drive.

MIRROR HUNTER This Mirror Bot is a multipurpose Telegram Bot writen in Python for mirroring files on the Internet to our beloved Google Drive. Repo la

Slam Mirror Bot is a multipurpose Telegram Bot written in Python for mirroring files on the Internet to our beloved Google Drive.
Slam Mirror Bot is a multipurpose Telegram Bot written in Python for mirroring files on the Internet to our beloved Google Drive.

Slam Mirror Bot is a multipurpose Telegram Bot written in Python for mirroring files on the Internet to our beloved Google Drive.

A Telegram Bot written in Python for mirroring files on the Internet to your Google Drive

No support is going to be provided of any kind, only maintaining this for vps user on request. This is a Telegram Bot written in Python for mirroring

A Telegram Bot written in Python for mirroring files on the Internet to Google Drive

No support is going to be provided of any kind, only maintaining this for vps user on request. This is a Telegram Bot written in Python for mirroring

A telegram bot writen in python for mirroring files on the internet to Google Drive
A telegram bot writen in python for mirroring files on the internet to Google Drive

owner of this repo :- AYUSH contact me :- AYUSH Slam Mirror Bot This is a telegram bot writen in python for mirroring files on the internet to our bel

Comments
  • Google OAuth Library Changes Invalidate Autodrive Authentication Procedure

    Google OAuth Library Changes Invalidate Autodrive Authentication Procedure

    Describe the bug A clear and concise description of what the bug is.

    To Reproduce Steps to reproduce the behavior:

    1. Attempt to instantiate any object that makes a connection to the Drive or Sheets API.

    Expected behavior Auth Flow should solicit Drive and Sheets CRUD rights and then successfully allow both Drive and Sheets CRUD simultaneously.

    bug 
    opened by chrislarabee 1
Releases(v0.6.3)
  • v0.6.3(Oct 2, 2021)

  • v0.6.2(Oct 2, 2021)

    Changelog

    • Added Autodrive stub files.
    • Fixed an issue with file uploading functionality that could cause multiple files to be accidentally created with the same parameters.
    Source code(tar.gz)
    Source code(zip)
  • v0.6.1(Sep 19, 2021)

  • v0.6.0(Sep 8, 2021)

    Changelog

    • Added file uploading features, including ability to upload files and convert them to appropriate Google formats.
    • Added data appending features to Tab.write_values and GSheet.write_values.
    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Aug 22, 2021)

    Changelog

    • Added append/delete/insert column(s) methods to Tab.format_grid.
    • Added set_alignment methods to format_text.
    • Made all FullRange arguments interchangeable with range strings in Google Sheet format (i.e. "A1:C10").
    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Aug 4, 2021)

    Changelog

    • Added support for hex color codes to Color interface.
    • Added set_border_format and set_background_color formatting functionality.
    • Improved write_values method functionality to allow a greater range of input data types.
    • Various performance improvements to underlying functionality related to batching requests.
    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Jul 24, 2021)

    Changelog

    • Added simple csv and json output methods to GSheet, Tab, and Range.

    Bug Fixes

    • Addressed issue #1, which involved a critical authentication fault caused by some changes Google made to the OAuth libraries underlying Autodrive's authentication procedure.
    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Jul 21, 2021)

    Changelog

    • Added more fleshed out documentation, including tutorials and guides.
    • Reworked RangeInterfaces to make them more intuitive and easy to use (also fixed a number of bugs in input parsing).
    • Added all the standard number formats used in Google Sheets' dropdown.
    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Jul 10, 2021)

Owner
Chris Larabee
Chris Larabee
A discord bot that utilizes Google's Rest API for Calendar, Drive, and Sheets

Bott This is a discord bot that utilizes Google's Rest API for Calendar, Drive, and Sheets. The bot first takes the sheet from the schedule manager in

null 1 Dec 4, 2021
A powerful bot to copy your google drive data to your team drive

⚛️ Clonebot - Heroku version ⚡ CloneBot is a telegram bot that allows you to copy folder/team drive to team drives. One of the main advantage of this

MsGsuite 269 Dec 23, 2022
A simple telegram Bot, Upload Media File| video To telegram using the direct download link. (youtube, Mediafire, google drive, mega drive, etc)

URL-Uploader (Bot) A Bot Upload file|video To Telegram using given Links. Features: ?? Only Auth Users (AUTH_USERS) Can Use The Bot ?? Upload YTDL Sup

Hash Minner 18 Dec 17, 2022
DB-Drive-CSV - This is app is can be used to access CSV file as JSON from Google Drive.

DB Drive CSV This is app is can be used to access CSV file as JSON from Google Drive. How To Use Create file/ upload file to Google Drive There's 2 fi

Hartawan Bahari M. 5 Oct 20, 2022
Google Sheets Python API

Google Spreadsheets Python API v4 Simple interface for working with Google Sheets. Features: Open a spreadsheet by title, key or url. Read, write, and

Anton Burnashev 6.2k Dec 30, 2022
Google Sheets Python API v4

pygsheets - Google Spreadsheets Python API v4 A simple, intuitive library for google sheets which gets your work done. Features: Open, create, delete

Nithin Murali 1.4k Jan 8, 2023
A Discord BOT that uses Google Sheets for storing the roles and permissions of a discord server.

Discord Role Manager Bot Role Manager is a discord BOT that utilizes Google Sheets for the organization of a server's hierarchy and permissions. Detai

Dion Rigatos 17 Oct 13, 2022
Fairstructure - Structure your data in a FAIR way using google sheets or TSVs

Fairstructure - Structure your data in a FAIR way using google sheets or TSVs. These are then converted to LinkML, and from there other formats

Linked data Modeling Language 23 Dec 1, 2022
Stop writing scripts to interact with your APIs. Call them as CLIs instead.

Zum Stop writing scripts to interact with your APIs. Call them as CLIs instead. Zum (German word roughly meaning "to the" or "to" depending on the con

Daniel Leal 84 Nov 17, 2022
Bagas Mirror&Leech Bot is a multipurpose Telegram Bot written in Python for mirroring files on the Internet to our beloved Google Drive. Based on python-aria-mirror-bot

- [ MAYBE UPDATE & ADD MORE MODULE ] Bagas Mirror&Leech Bot Bagas Mirror&Leech Bot is a multipurpose Telegram Bot written in Python for mirroring file

null 4 Nov 23, 2021