Editing Google Docs (Even Shared) using Python

A couple of hacking sessions later and it works. Essentially the documentation leaves some to wish for but essentially the basics is covered by the github-example. Which is not really an example by any mean, but its as good as it gets. Firstly a few concepts: The meta data is what matters and especially the ‘id’-tag. That is needed to make changes to an existing document. To get it one must query the file listings. If an uploaded file does not have an existing ‘id’, a new file will be created.

Once the ‘id’ is in place its possible to download a copy – an exported copy in e.g. HTML format to a local file. The local file can then be edited or manipulated locally with xml-parsing etc and then uploaded again to a file with the same ‘id’ and ‘title’. This is one way of ‘editing’ google docs on the fly.

So why is this interesting? We have shared google docs for our labs that contain information about who’s where and whats going on. Since we installed it I have wanted to play around with how it could be extended with various kinds of interactive devices (hence the RPI), information from the cloud (i.e. weather data) or local information like a “buisiness’o’meter”. I’m sure there are many more possibilities, but it would be interesting to explore what ideas people could have that we could test out.

https://github.com/googledrive/PyDrive