-1

I'm trying to create a variable with multiple numbers which is then parsed into a code to delete multiple rows via Smartsheet API.

This is how it works:

smartsheet_client.Sheets.delete_rows(
  3637721312342212,  #sheet_id
  [567387105060740, 4908041578801028]) #row_id

I would like to parse multiple numbers by assigning it to a variable beforehand, but it doesn't work. I wonder if the brackets are the problem when parsing the variable.

row_ids = 567387105060740, 4908041578801028
print(row_ids)
(567387105060740, 4908041578801028)

smartsheet_client.Sheets.delete_rows(
      3637721312342212,  #sheet_id
      [row_ids]) #row_id

If I get the variable to work, I wonder how to transform all the values of one column (example below) into the same format to create a variable with the respective numbers.

From:

0    4738432649193348
1    5625432649192019
2    6321432649125716
   Name: row_id_column, dtype: Int64

To (I guess tuple):

row_id_column = 4738432649193348, 5625432649192019, 6321432649125716
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
TobeT
  • 3
  • 1

1 Answers1

0

The .delete_rows() function requires a list of row ids (integers).

row_ids = 567387105060740, 4908041578801028

The above will create a tuple with the row ids. Instead, you need:

row_ids = [567387105060740, 4908041578801028]

From here, your code should look like:

row_ids = [567387105060740, 4908041578801028]
smartsheet_client.Sheets.delete_rows(
  3637721312342212,  #sheet_id
  row_ids) # list of row ids

Note the removed []. Your current method [row_id] will send a list of tuples [(567387105060740, 4908041578801028)] instead of the required list of integers.