reading google gdoc in python

Question:

I am trying to develop a workflow to convert some txt files saved in google drive into markdown files using python. Below is the overview of what i am trying to do.

  • The txt files are being uploaded to google drive.
  • I was hoping I would access my google drive files on my local synced google drive folder, through python on my computer read the .txt file and convert into .md.
  • But google drive seems to convert those .txt files into .docx.gdoc format. I can’t read that file in python.

I tried the following

  • python read write with file open.
  • installed python-docx and tried to do it that way
  • tried to use pdfs instead of txt files but my input system does not allow to do it.
Asked By: Nikhil Kondabala

||

Answers:

It is important to clarify that Google Drive does not convert ".txt" files. It has a built in feature that can convert ".docx" files to Google Docs, however this generally only works with Microsoft files.

enter image description here

It opens the ".txt" files directly with Google Docs but does not convert them to "gdocs".

If you are locally syncing the ".txt" over your computer, there are certain limits from the application itself (Google Drive for Desktop) on how files are being accessed offline using the tool

It is interesting to note that multiple discussions exist to make covert files from Docs to ".md".

I would highly suggest reviewing the discussion on utilizing the option to either export or fetch the Drive document into "docx: and converting to "markdown".

The majority of suggestions would link the option to use Pandoc to convert
them utilizing Drive API.

Reference: