Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Alex's answer, while undoubtedly correct, begs the question: "how do I do that via the Google Docs API?" </p> <p>Here's a way (in Python, 'cause I'm that kind of guy):</p> <pre><code>import gdata.docs.service import StringIO client = gdata.docs.service.DocsService() client.ClientLogin(username, password, source='Spreadsheet Creation Example') content = 'COL_A, COL_B, COL_C, COL_D\ndata1, data2, data3, data4' ms = gdata.MediaSource(file_handle=StringIO.StringIO(content), content_type='text/csv', content_length=len(content)) entry = client.Upload(ms, 'Test Spreadsheet') </code></pre> <p>This is a small mashup of techniques that I found in <a href="http://code.google.com/p/gdata-python-client/source/browse/tests/gdata_tests/docs/service_test.py" rel="noreferrer">http://code.google.com/p/gdata-python-client/source/browse/tests/gdata_tests/docs/service_test.py</a> , which I in turn found via <a href="http://www.mail-archive.com/google-docs-data-apis@googlegroups.com/msg01151.html" rel="noreferrer">this post</a> from the Google Group for the GData Docs API. </p> <p>The key insights (for me anyway) were: </p> <ol> <li>realizing that the MediaSource constructor's formal parameter "file_handle" will take any file-like object, and </li> <li>discovering (as the OP's followup to the Google Group post mentions) that the unit tests are a great source of examples</li> </ol> <p>(I wasn't able to find the Python-specific developer's guide referenced by Alex's doc link -- possibly it's been lost or buried in Google's move of documentation assets from code.google.com to developers.google.com. Alex's link now redirects to the more generic document that shows mostly .NET and Java examples, but only a little Python.)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload