Skip to content

Instantly share code, notes, and snippets.

View jmyzk's full-sized avatar

jmyzk jmyzk

View GitHub Profile
@jmyzk
jmyzk / gist:b6a10d66d85654deb1fd0205d798c300
Created June 9, 2023 09:27
How to programmatically erase a date column cell, with project settings and dependencies enabled?
import smartsheet
def remove_start_date(sheet_id, row_number):
access_token = "" # your access token
smartsheet_client = smartsheet.Smartsheet(access_token)
sheet = smartsheet_client.Sheets.get_sheet(sheet_id)
# Create Column Map
column_map = {}
for column in sheet.columns:
@jmyzk
jmyzk / main.py
Last active June 15, 2023 08:10
Import a CSV file with more than 10,000 and 10 columns to Smartsheet
import os
import smartsheet
import csv
# Uncomment and set your Smartsheet API access token
# access_token = 'YOUR_ACCESS_TOKEN'
# Initialize the Smartsheet client
client = smartsheet.Smartsheet(access_token)
def delete_rows_in_batches(sheet_id, batch_size=300):
row_ids = [row.id for row in smartsheet_client.Sheets.get_sheet(sheet_id).rows]
num_rows = len(row_ids)
num_batches = (num_rows // batch_size) + 1
for i in range(num_batches):
start_index = i * batch_size
end_index = min(start_index + batch_size, num_rows)
batch_row_ids = row_ids[start_index:end_index]