RickRollNGo RickRollNGo - 3 months ago 36
Python Question

Retrieving SmartSheet Content using Python SDK

so ill try to keep this short as possible. I am a newbie to the SmartSheet Python SDK and im trying to call all the data from the Smartsheet and hopefully use that as a starting point for myself. So far what I have

import smartsheet

smartsheet = smartsheet.Smartsheet('token1')


Which I am running/compile on Python Shell, and so far with those two lines I am running it and not getting an issue, when I try to implement anything else to pull the data, I keep getting errors.

on topic but a separate thing

I also have this line of code to pull specific line from the SmartSheet,

action = smartsheet.Sheets.get_sheet(SheetID, column_ids=COL_ID, row_numbers="2,4")


My question regarding this is, where do I find the Column ID, I know how to access the Sheet ID, but I cant access or find the Column ID on smartsheets, I dont know if i am overlooking it. Just looking to get off in the right direction, being the newbie I am, any help appreciated.

EDIT

5183127460046724
Task Name

2931327646361476
Duration

7434927273731972
Start

Answer

The following sample code retrieves a list of all columns from the specified Sheet, and then iterates through the columns printing out the Id and Title of each column. (You'll obviously need to replace ACCESS_TOKEN and SHEET_ID with your own values.)

# Import.
import smartsheet

# Instantiate smartsheet and specify access token value.
smartsheet = smartsheet.Smartsheet('ACCESS_TOKEN')

# Get all columns.
action = smartsheet.Sheets.get_columns(SHEET_ID, include_all=True)
columns = action.data

# For each column, print Id and Title.
for col in columns:
    print(col.id)
    print(col.title)
    print('')
Comments