Frage

My Spreadsheet is in format

1  2
3  4

I am using the following code:

username = 'username@gmail.com'
passwd = 'mypassowrd'
doc_name = 'mydocument'
import gdata.docs
import gdata.docs.service
import gdata.spreadsheet.service
import re, os

gd_client = gdata.spreadsheet.service.SpreadsheetsService()
gd_client.email = username
gd_client.password = passwd
gd_client.ProgrammaticLogin()
q = gdata.spreadsheet.service.DocumentQuery()
q['title'] = doc_name
q['title-exact'] = 'true'   

feed = gd_client.GetSpreadsheetsFeed(query=q)
spreadsheet_id = feed.entry[0].id.text.rsplit('/',1)[1]
rows = gd_client.GetListFeed(spreadsheet_id, worksheet_id).entry
print rows

for row in rows:
    for key in row.custom:
        print " %s: %s" % (key, row.custom[key].text)

But it is only printing 3 and 4, How can i print the complete spreadsheet, preferably in a dict ?

War es hilfreich?

Lösung

Figured out the first row is treated as header, so if i give names like

a  b
1  2
3  4

then the output would be perfect:

a:1
b:2

a:3
b:4
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top