Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to interpret google docs gdata atom.Content in python

Posted on 2011-02-17
4
Medium Priority
?
592 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Flask is a microframework for Python based on Werkzeug and Jinja 2. This requires you to have a good understanding of Python 2.7. Lets install Flask! To install Flask you can use a python repository for libraries tool called pip. Download this f…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
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 …
Suggested Courses

597 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