使用 Python SDK 检索 SmartSheet 内容

Retrieving SmartSheet Content using Python SDK

所以我尽量保持简短。我是 SmartSheet Python SDK 的新手,我正在尝试调用 Smartsheet 中的所有数据,并希望将其用作我自己的起点。到目前为止我有

import smartsheet

smartsheet = smartsheet.Smartsheet('token1')

我在 Python Shell 上 running/compile,到目前为止,当我尝试使用这两行时,我 运行 它并没有遇到问题实施任何其他方法来提取数据,我不断收到错误。

关于主题,但另一件事

我也有这行代码可以从 SmartSheet,

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

我的问题是,在哪里可以找到列 ID,我知道如何访问 Sheet ID,但我无法在智能表上访问或找到列 ID,我不知道我是不是俯瞰它。只是希望朝着正确的方向下车,作为我的新手,任何帮助表示赞赏。

编辑

5183127460046724
Task Name

2931327646361476
Duration

7434927273731972
Start

编辑 2

Task Name
task1 text here


Duration
duration1 text here

Start
start1 example here

以下示例代码从指定的 Sheet 中检索所有列的列表,然后遍历列打印出每列的 ID 和标题。 (您显然需要将 ACCESS_TOKENSHEET_ID 替换为您自己的值。)

# 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('')

更新#1

下面是一些示例代码,展示了如何在 Get Sheet 响应中访问 属性 值。

# Get Sheet - but restrict results to just 2 rows (#2, #4) and a single column/cell (Id = COLUMN_ID)
action = smartsheet.Sheets.get_sheet(SHEET_ID, column_ids=COLUMN_ID, row_numbers="2,4") 

# print info from row #2 (the first row in the "Get Sheet" response) for the single specified column (cell)
print('Row #: ' + str(action.rows[0].row_number))
print('Row ID: ' + str(action.rows[0].id))
print('Column ID: ' + str(action.columns[0].id))
print('Column Title: ' + action.columns[0].title)
print('Cell (display) value: ' + action.rows[0].cells[0].display_value)
print('')

# print info from row #4 (the second row in the "Get Sheet" response) for the single specified column (cell)
print('Row #: ' + str(action.rows[1].row_number))
print('Row ID: ' + str(action.rows[1].id))
print('Column ID: ' + str(action.columns[0].id))
print('Column Title: ' + action.columns[0].title)
print('Cell (display) value: ' + action.rows[1].cells[0].display_value)
print('')