Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

The DeleteRow function results in the deletion of every other row when iterating through a ListFeed in a spreadsheet using python gdata in New Google Spreadsheets #2

Closed

Description

@ksiadmin

I am having a problem using the DeleteRow function in New Google Spreadsheets.

I have prepared a NEW google spreadsheet and entered multiple rows of data into the worksheet. For example, I put the following in column A, each on its own row: ID, 1,2,3,4,5,6,7,8,9,10,11,12

Then I perform deleterow() in a loop over a ListFeed as follows:

import gdata.spreadsheet.service
import gdata.service

ss_key = “google spreadsheet key";

gd_client = gdata.spreadsheet.service.SpreadsheetsService();

...
gd_client.ProgrammaticLogin();

feed = gd_client.GetWorksheetsFeed(ss_key);
worksheetID = feed.entry[int(feed.total_results.text)-1].id.text.rsplit('/', 1)[1]
listFeed = gd_client.GetListFeed(ss_key, worksheetID);

for row in listFeed.entry:
gd_client.DeleteRow(row)

The expected output would be for the rows except the header to be deleted. What I see is that rows 2,4,6,8,10 and 12 remain. If I run it again, rows 4,8,12 remain. It is deleting every other row.

I am using gdata 2.0.18 and new google spreadsheets

This approach continues to work the old google spreadsheets. It does not work with the new google spreadsheets.

Activity

  1. kjumpei commented on Feb 5, 2015

    @kjumpei

    Hi. Is this problem resolved,or not yet?
    I have same issue and old spreadsheet is worked too.

  2. ksiadmin commented on Feb 5, 2015

    @ksiadmin
    Author

    Still not resolved

  3. kjumpei commented on Feb 6, 2015

    @kjumpei

    thanks.

  4. aliafshar commented on Feb 10, 2015

    @aliafshar
    Contributor

    Likely this is not a client library bug, sorry. If the only difference is New vs Old spreadsheets. @erickoledadevrel

  5. erickoledadevrel commented on Feb 13, 2015

    @erickoledadevrel

    It looks like the behavior or row IDs have changed in New Sheets, such that the IDs change when rows are deleted. Deleting row 1 causes row 2 to become row 1 and take on it's ID, and row 3 to take on row 2's ID, etc. This would lead to the behavior you are reporting, where only alternating rows are being deleted.

    This is a bug with the Spreadsheets API and New Sheets, and should be reported here:

    https://code.google.com/a/google.com/p/apps-api-issues/issues/list

    You can work around this issue by deleting rows in reverse order (from bottom to top). This is not something that can be fixed in the client library however, so this issue should be closed.

  6. ksiadmin commented on Feb 13, 2015

    @ksiadmin
    Author

    Thank you, I can use that work around! And I posted this at https://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3739
    and this can be closed

  7. kjumpei commented on Feb 14, 2015

    @kjumpei
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions