Is there any way of uploading data into Smartsheet in batches?
Still fairly new playing around with Python and Smartsheet's API.
The full script have works, its just I have 10000+ rows I want to upload.
The script below is what I use to delete the information from the sheet in batches.
# Get the rows from the sheet
sheet = smartsheet_client.Sheets.get_sheet(sheet_id)
rows = sheet.rows
# Collect the row IDs
row_ids = [row.id for row in rows]
# Maximum number of rows to delete in a single request
batch_size = 350 # Adjust this as needed
# Delete rows in batches with status bar
for i in tqdm(range(0, len(row_ids), batch_size), desc="Deleting rows"):
batch_ids = row_ids[i:i+batch_size]
smartsheet_client.Sheets.delete_rows(sheet_id, batch_ids, ignore_rows_not_found=True)
This is what I currently have uploading the data. Its getting the data from a csv.
# Create cells for the new row
cells = []
for column_id, cell_value in zip(column_ids, row_data):
cell = smartsheet_client.models.Cell({
'column_id': int(column_id), # Convert string to integer
'object_value': cell_value
})
cells.append(cell)
# Create a new row with the cells
row = smartsheet_client.models.Row({'cells': cells})
# Add the row to the sheet
smartsheet_client.Sheets.add_rows(sheet_id, [row])