Sorry, I did not see your post until now. Perhaps you figured this out
already. I haven't yet figured out how to create a new spreadsheet and
put data into it. But I did figure out how to easily get the contents
of an existing spreadsheet. Some code is below. Did you figure out how
to create a new spreadsheet, and put data into it?

Thanks
  -- Dave

   client = gdata.spreadsheet.service.SpreadsheetsService()
   session_token = client.token_store.find_token('http://
spreadsheets.google.com/feeds/')
   gdata.alt.appengine.run_on_appengine(client)

  sfeed = client.GetSpreadsheetsFeed()

  skey = sfeed.entry[0].id.text.rsplit('/', 1)[1]

  sfeed = client.GetWorksheetsFeed(skey)

  # print list of spreadsheet names
  self.response.out.write("<ul>")
  for i, s in enumerate(sfeed.entry):
    self.response.out.write("<li>" + s.id.text + "</li>")
  self.response.out.write("</ul>")

  # print contents of the first worksheet in the list
  wkey = sfeed.entry[0].id.text.rsplit('/', 1)[1]

  self.response.out.write("<p>" + skey + ":" + wkey + "</p>")

  sfeed = client.GetListFeed(skey, wkey)
    self.response.out.write("<p>" + PrintFeed(sfeed) + "</p>")

def PrintFeed(feed):
  out = ""
  out = "<table border=2>"

  for i, entry in enumerate(feed.entry):
    if isinstance(feed, gdata.spreadsheet.SpreadsheetsCellsFeed):
      out = out + 'cells feed: ' + '%s %s\n' % (entry.title.text,
entry.content.text)
    elif isinstance(feed, gdata.spreadsheet.SpreadsheetsListFeed):
      out = out + '<tr>'
      for key in entry.custom:
        out = out + '<td>%s</td>' % entry.custom[key].text
      out = out + '</tr>'
    else:
      out = out + 'other feed: ' + '%s %s\n' % (i, entry.title.text)
  out = out + "</table>"

  return out




On Sep 4, 2:50 am, marco <ma...@enterz.nl> wrote:
> HiDave,
>
> I'm currently struggling with the same problem. What I basically want
> to do is copy a spreadsheet from folder A to folder B.
> Because this is not possible with the API (yet?), I wanted to try the
> same thing you tried: create new spreadsheet, export old data and
> import to new file.
> This all in a app engine application. (python)
>
> Below you said you figured out how to do this. Do you have a code
> example, or could you give me some pointers on how you did this?
>
> Thanks in advance!
>
> ~Marco
>
> On Aug 22, 3:56 am,Dave<dabo...@gmail.com> wrote:
>
> > Thanks, I will give this a try.  It seems though that I shouldn't have
> > to use a new, untested method for this. Isn't there an established way
> > to do this? Should I instead be using the Spreadsheets API perhaps? If
> > so, can I access it using the same auth session token that my program
> > already obtains forhttp://docs.google.com/feeds?(2questions,
> > really)
>
> > Thanks,
> >Dave
>
> > On Aug 21, 2:56 pm, "Jeff S (Google)" <j...@google.com> wrote:
>
> > > HiDave,
>
> > > Great find, yes it seems that the Documents API design is somewhat App
> > > Engine un-friendly. I've filed a bug to remedy this.
>
> > >http://code.google.com/p/gdata-python-client/issues/detail?id=278
>
> > > My proposed solution, not yet tested, to replace the _DownloadFile method 
> > > in
> > > gdata.docs.service to something like the following
>
> > >   def _GetFile(self, uri, file_handle):
> > >     server_response = self.request('GET', uri)
> > >     if server_response.status != 200:
> > >       raise gdata.service.RequestError, {'status': server_response.status,
> > >                                          'reason': server_response.reason,
> > >                                          'body': server_response.read()}
> > >     file_handle.write(server_response.read())
>
> > >   def _DownloadFile(self, uri, file_path):
> > >     """Downloads a file.
>
> > >     Args:
> > >       uri: string The full Export URL to download the file from.
> > >       file_path: string The full path to save the file to.
>
> > >     Raises:
> > >       RequestError: on error response from server.
> > >     """
> > >     f = open(file_path, 'wb')
> > >     try:
> > >       self._GetFile(uri, f)
> > >     except gdata.service.RequestError, e:
> > >       f.close()
> > >       raise e
> > >     f.flush()
> > >     f.close()
>
> > > I haven't tested this yet but if you are feeling brave feel free to try it
> > > out. You could then call _GetFile directly and pass in a StringIO object 
> > > for
> > > your file handle.
>
> > > Happy coding,
>
> > > Jeff
>
> > > On Thu, Aug 20, 2009 at 6:12 AM,Dave<dabo...@gmail.com> wrote:
>
> > > > I'm using gdata.docs.service to download a list of a user's
> > > > spreadsheets using GetDocumentListFeed. I want to now let the user
> > > > select a specific spreadsheet so my app can download its contents, do
> > > > some manipulation, and then save a copy of the modified spreadsheet
> > > > back to their Google Docs account (with a new filename).
>
> > > > To grab the contents of their spreadsheet, I thought I could use the
> > > > "Download" method on the results of GetDocumentListFeed.
> > > > Unfortunately, this method requires a location to write the downloaded
> > > > file to, and AppEngine doesn't let its apps write files to disk (or so
> > > > I've read). So what is the recommended way to do this? I'd be happy
> > > > getting the contents of the file as a data structure in memory,
> > > > containing something like csv data. I don't need to deal with XML. Any
> > > > suggestions, or pointers to documentation, would be appreciated.
>
> > > > Thanks,
> > > >Dave
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to