Solved

How to interpret google docs gdata atom.Content in python

Posted on 2011-02-17
4
588 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

726 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