1

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?

rain
  • 363
  • 6
  • 15
  • 2
    If there's no direct way that you can find, a workaround could be to download the document in some format like .docx, then use a library that can edit that document format, do the editing with that library, and then upload it. – Random Davis Mar 26 '21 at 22:54
  • 1
    Does this answer your question? [editing google doc programmatically](https://stackoverflow.com/questions/5482925/editing-google-doc-programmatically) – CryptoFool Mar 26 '21 at 22:58
  • Are you already able to connect to google drive? via oauth or something else? Maybe show us some of your code. – Simon Mar 26 '21 at 23:06
  • Although I'm not sure whether this is the direction you expect, for example, how about using the method of documents.batchUpdate in Google Docs API? [Ref](https://developers.google.com/docs/api/reference/rest/v1/documents/batchUpdate) In this case, you can use googleapis for python. [Ref](https://developers.google.com/docs/api/quickstart/python) – Tanaike Mar 27 '21 at 01:29
  • @CryptoFool I will try that. Will have to check how effectively I can edit the document. I may need to use rich features similar to Microsoft word. So, will give it a try thanks. – rain Mar 27 '21 at 02:59
  • @Tanaike do you mean updating the document using json style format? Never tried that. Will check the link, thanks. – rain Mar 27 '21 at 03:00
  • @RandomDavis Yes that was my next plan :) To use python-docx for editing. – rain Mar 27 '21 at 03:02
  • Also, found this link which is very helpful. https://mdeore.medium.com/automated-documents-google-docs-api-97df5602660e – rain Mar 27 '21 at 03:32

1 Answers1

0

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

rain
  • 363
  • 6
  • 15