Using smartsheet-python-sdk to put data back into Smartsheet
I used the smartsheet-python-sdk (and unique API key from Smartsheet) to automatically pull data from Smartsheet into my Python script along with other data sources to create new feature-engineered columns. Is there an automatic way to now put these new columns I created back into the same Smartsheet I initially pulled data from using the smartsheet-python-sdk? Thank you!
Answers
-
I re-read your question and the answer is still yes but how you go about it would be different.
Add columns: https://smartsheet-platform.github.io/api-docs/?python#add-columns
I would assume, depending on how many columns you have, you could use a for loop to populate the necessary information in the column specification.
Here's an example where I took the columns from one sheet, put them in a list, and then wrote them to another sheet in a batch.
column_to_add = [ ]
for column in new_sheet.columns:
column_model = smartsheet.models.Column({'title': column.title, 'type': 'TEXT_NUMBER', 'index': col_index})
columns_to_add.append(column_model)
new_columns = ss_client.Sheets.add_columns(target sheet ID, columns_to_add)
If you need to populate those rows with specific data that is also possible by updating rows, but it could get more complex (I think) depending on what exactly you're trying to do.
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 63.5K Get Help
- 402 Global Discussions
- 213 Industry Talk
- 450 Announcements
- 4.7K Ideas & Feature Requests
- 141 Brandfolder
- 135 Just for fun
- 56 Community Job Board
- 454 Show & Tell
- 31 Member Spotlight
- 1 SmartStories
- 296 Events
- 36 Webinars
- 7.3K Forum Archives