Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing to a Google Document With Python

I have some data that I want to write to a simple multi-column table in Google Docs. Is this way too cumbersome to even begin attempting? I would just render it in XHTML, but my client has a very specific work flow set up on Google Docs that she doesn't want me to interfere with. The Google Docs API seems more geared toward updating metadata and making simple changes to the file format than it is toward undertaking the task of writing entire documents using only raw data and a few formatting rules. Am I missing something, or are there any other libraries that might be able to achieve this?

like image 931
user1427661 Avatar asked Nov 04 '22 07:11

user1427661


1 Answers

From the docs:

What can this API do?

The Google Documents List API allows developers to create, retrieve, update, and delete Google Docs (including but not limited to text documents, spreadsheets, presentations, and drawings), files, and collections.

So maybe you could save your data to an excel worksheet temporarily and then upload and convert this.

Saving to excel can be done with xlwt:

import xlwt
workbook = xlwt.Workbook()
sheet = workbook.add_sheet('Sheet 1')
sheet.write(0,1,'First text')
workbook.save('test.xls')
like image 54
Thorsten Kranz Avatar answered Nov 12 '22 20:11

Thorsten Kranz