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
- 64.2K Get Help
- 419 Global Discussions
- 221 Industry Talk
- 461 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 141 Just for fun
- 58 Community Job Board
- 462 Show & Tell
- 32 Member Spotlight
- 1 SmartStories
- 299 Events
- 38 Webinars
- 7.3K Forum Archives