How to update multiple rows at once

Does the update_rows() function allow for multiple rows to be referenced? I am working on creating a sheet that needs to have the most up-to-date data which comes from a database. If data in the database changes, I would like to be able to make the necessary updates to all the rows affected. I'm working with large amounts of data so I was wondering if this function would be able to make the updates for me at once.

Answers

  • BKing
    BKing ✭✭✭

    We tend to maintain a (sorry c#):

    List<rows> rowsToUpdate as a set of change values.

    So, run round our update loop and change all the required cells on every row that needs to be changed.

    And then call UpdateRows:

            IList<Row> updatedRow = smartsheet.SheetResources.RowResources.UpdateRows(

             sheetId, rowsToUpdate);

  • Hi Bking,


    I'm having 1000 rows which needs to be updated and some rows to be added via smartsheet API method in UiPath. It's taking time, Could you please suggest fastest method and I'm having unique ID as well.


    Thanks,

    Sandhiya P

  • Topio
    Topio ✭✭

    it is crazy that this functionality is not available here.
    It is standard in trello and monday.com

  • Alex Argumedo
    Alex Argumedo ✭✭✭✭✭
    edited 09/17/24

    The way you can bulk update rows:

    do the same you are doing to build a single row, but initiate a list (python)

    rows_to_update = []

    each time you have a new row ready to update, append to this list

    rows_to_update.append(row)

    depending of the number of columns in the sheet you can update every 200 or so rows update the sheet using the list (see below) and initialize it and continue, this bulk action can save a lot of time. if you only have a few columns to update, you can even make it to 500 rows at the time.

    then use:

    updated_row = smartsheet_client.Sheets.update_rows(<sheet id>, rows_to_update)

    rows_to_update = []