I am using python and writing a script to create a google document with PyDrive, upload it to google drive and modify the document as well. I am following the instructions from pydrive documentation (https://pypi.org/project/PyDrive/).
So far, I am able to create a document, upload/download and set permissions. I am looking for other capabilities from pydrive like modifying the document, adding paragraph, set font or insert table from the python script. I see all this in python-docx (https://python-docx.readthedocs.io/en/latest/). Do we have this in google drive api using pydrive as well?
I am able to achieve this using google doc APIs as suggested. Reference to this is developers.google.com/docs/api/how-tos/documents
Google doc API
Related
I am working on a Google Colab notebook that requires the user to mount google drive using the colab.drive python library. They then input relative paths on the local directory tree (/content/drive/... by default on that mount) to files of interest for analysis. Now, I want to use a Google Sheet they can create as a configuration file. There is lots of info on how to authenticate gspread and fetch a sheet from its HTTPS url, but I can't find any info on how to access the .gsheet file using gspread that is already mounted on the local filesystem of the colab runtime.
There are many tutorials using this flow: https://colab.research.google.com/notebooks/io.ipynb#scrollTo=yjrZQUrt6kKj , but I don't want to make the user authenticate twice (having already done so for the initial mount), and i don't want to make them input some files as relative path, some as HTTPS URL.
I had thought this would be quite like using gspread to work with google sheets that I might have on my locally mounted drive as well. But, I haven't seen this workflow anywhere either. Any pointers in that direction might help me out as well.
Thank you!
Instead of adding .gsheet on colab's drive you can try storing it in the user's drive and later fetch from there when needed. So until that kernel is running you won't have to re-authenticate the user.
I'm also not finding anything to authenticate into colab from other device. So you would consider modifying your flow a bit.
I have a project that is running a python script in a GitHub repo that reads and updates a local CSV file. Is it possible to save the updated CSV file on the GitHub repo using that py script? Calling and saving the file to my GoogleDrive won't work because it is a public GitHub repo, so I cannot store my Google credentials.
Does anyone have a solution? Or know a cloud provider that will read/write access to non-users accounts?
You can check out PyGithub, from their docs:
PyGitHub is a Python library to access the GitHub REST API. This
library enables you to manage GitHub resources such as repositories,
user profiles, and organizations in your Python applications.
Or GitPython
GitPython is a python library used to interact with git repositories,
high-level like git-porcelain, or low-level like git-plumbing.
Cheers!
I am pretty new Google app engine, and though I have hacked around with alot of languages, I am finding the google documentation a little overwhelming. I have successfully launched a static site, and successfully run some python code from the console. But I have not run any python from my static site.
I am a Small company trying to setup a google app engine static/dynamic website that I only want to expose to my Gsuite users.
I have some python code I want to run on my app engine, which will download a file from gdrive/teamdrive, process the file, create a new file from the results and then upload the resulting file to the same folder.
I may also at a later date have this static/dynamic website also interfacing with Cloud SQL(mysql) or an external database.
my Questions
What authentication method to use to only expose this website to my gsuite users?
Though I have worked through some of the GDrive api examples whats the best and easiest method of passing GDrive text files to my python code? (though I have hacked around with python lots in the past, the html and python combination perplexes me)
Thanks!
You would use OAuth2.0 to acquire a token which you can then use to interact with that user's files through the GDrive API (see "About Authorization" as well as this quickstart Python example).
For Google Spread Sheet, gsperad is a great tool to access, modify and retrieve Google SpreadSheet.
Is there a tool for Google Docs, to access and modify Googel Docs document in Python?
Thank you very much
Google has a Google Doc API for use with Python. Please refer to the following links for more information:
Drive API Client Library for Python
Quickstart: Run a Drive App in Python
I want to develop a backup app, I wish that the app will be able only to upload files without any permissions to delete files (or any other permission).
is it possible ?
Yes, it's possible. Start by looking for a python library that lets you communicate with the Google Drive API. See Google APIs Client Library and PyDrive (you'll find easy code as example here).