
The solution to the OP is to perform similar operations as what you see in both posts above but ensure you're using the text/plain export MIMEtype. Post above uses Drive API v2 this follow-up post describes migrating it to Drive API v3, and here's a developer video combining both "poor man's converter" posts. (*) - TL DR: upload plain text file to Drive, import/convert to Google Docs format, then export that Doc as PDF. "Poor man's plain text to PDF" converter ( blog post) (*).
Exporting a Google Sheet as CSV ( blog post). To read plain text from a Google Doc, considered file-level access, you would use the Google Drive API instead. There isn't a REST API available (at this time) for Google Docs documents, although there is an "API-like" service provided by Google Apps Script, the JavaScript-in-the-cloud solution which provides programmatic access to Google Docs (via its DocumentService object), including Docs add-ons. While not all GData APIs have been deprecated, all newer Google APIs do not use the Google Data protocol. (Feb 2017) The code in the OP and the only other answer are both now out-of-date as ClientLogin authentication was deprecated back in 2012(!), and GData APIs are the previous generation of Google APIs. If you want to programmatically CRUD different parts of a Doc, then you must use either the Docs API or Apps Script. (The Drive API works on both Python 2 & 3, but Apps Script is JavaScript-only.)īottom-line: if you want to download the entire Doc in plain text, the Drive API solution is best.
#Google drive plain text editor how to
More info about it from my SO answer to a similar question, but to get you going, here's the official Python "quickstart" sample showing you how to get the title of a Google Doc in plain text.īoth the Apps Script and Drive REST API solutions originally answered below are still valid and are alternate ways to get the contents of a Google Doc. UPDATE (Mar 2019) Good news! The Google Docs REST API is now available.