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
- Customer Resources
- 64.9K Get Help
- 439 Global Discussions
- 138 Industry Talk
- 470 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 67 Community Job Board
- 486 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives