Solved

How to interpret google docs gdata atom.Content in python

Posted on 2011-02-17
4
580 Views
Last Modified: 2012-05-11
I am trying to import data from a google spreadsheet and programatically create objects from it.  I have been able to see the data but cant understand how to process each filed.  I have attached the code I have so far.

How do I access the fields of data and create objects from them.  It looks like a dictionary object but I cant read the fields by name.


import gdata
import gdata.spreadsheet.service
import gdata.docs.service
import atom.core

gd_client = gdata.spreadsheet.service.SpreadsheetsService()
gd_client.email = 'firstname.lastname@gmail.com'
gd_client.password = 'password'
gd_client.source = 'my-exporter-1'
gd_client.ProgrammaticLogin()

key = 'biglongggoledockey'

def ListGetAction(gd_client, key, wksht_id):
  # Get the list feed
  feed = gd_client.GetListFeed(key, wksht_id)
  for line in feed.entry:
      print line.content.text

Open in new window

0
Comment
Question by:Aaran_Stent1
  • 3
4 Comments
 
LVL 16

Expert Comment

by:Kalpesh Chhatrala
ID: 34923698
0
 

Author Comment

by:Aaran_Stent1
ID: 34930087
i have spent a long time reading the api.  i just need a example of how to iterate through  the atom feed/content please.
0
 

Accepted Solution

by:
Aaran_Stent1 earned 0 total points
ID: 34930697
Found the solution i was looking for...

http://gdatatips.blogspot.com/2008/07/access-spreadsheets-list-feed-elements.html


# print out dictionary of row information for each row  
for entry in worksheet_list_feed.entry:  
  for key in entry.custom:  
    print '%s: %s' % (key, entry.custom[key].text)

Open in new window

0
 

Author Closing Comment

by:Aaran_Stent1
ID: 34959273
I searched for the spreadsheet object and found the example rather than the atom content object i was looking at
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

"The time has come," the Walrus said, "To talk of many things: Of sets--and lists--and dictionaries-- Of variable kinks-- And why you see it changing not-- And why so strange are strings." This part describes how variables and references (see …
Dictionaries contain key:value pairs. Which means a collection of tuples with an attribute name and an assigned value to it. The semicolon present in between each key and values and attribute with values are delimited with a comma.  In python we can…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now