15899

How to get the array of sheet ids in a folder with python

Question:

When I try to get the id array from the get.folder() call (by using folder = folder.sheets.id), I get the answer: "AttributeError: 'TypedList' object has no attribute 'id'" I'm not sure what function to call in python to get the array of sheet ids in the folder.

I am trying to do this with the python smartsheet sdk, but I am not sure exactly how to format it.

inc_list = ['all'] # you can add other parameters here, separated by a comma response = ss_client.Folders.copy_folder( folderID, # folder_id ss_client.models.ContainerDestination({ 'destination_id': destinationID, 'destination_type': 'folder', 'new_name': cellValue }), include=inc_list ) copiedFolderID = response.result.id folder = ss_client.Folders.get_folder( copiedFolderID) # folder_id newFolder = folder.sheets.id print (newFolder)

Also thanks for helping answer my questions, I really appreciate it.

Answer1:

folder.sheets is an array. The reason you're getting an error is because there is no id attribute at the array level - you need to look at the individual elements inside the array.

Take a look at the <a href="https://smartsheet-platform.github.io/api-docs/#get-folder" rel="nofollow">API docs</a> to get an example of what you'd receive.

sheet_ids = [] for sheet in folder.sheets sheet_ids.append(sheet.id) print(sheet_ids)

Answer2:

To get a list of the sheetIds for sheets in a folder, your Python would look something like this.

my_folder = ss_client.Folders.get_folder(folder_id) for sheet in my_folder.sheets: print(sheet.id)

Recommend

  • Using New Google API Console project getting unauthorized_client ,Client is unauthorized to retrieve
  • Why can't i have slashes in my rewrite rule?
  • TypeError: Cannot find function hasNext in object (Folder with date ID)
  • Create folders from folder id and parent id in java
  • What distributed message queues support millions of queues?
  • How to share a database between ASP.NET MVC 5 application and .NET console application?
  • Plot a CSV file where the delimiter is '; ' (semicolon + space)
  • Invoking a controller's action by button in View without redirecting to any view
  • Duplicate identifier error when referencing a node library using typescript
  • How to remove comma or any characters from Python dataframe column name
  • Get variable height for a UIButton for iPhones 5/6/6+
  • Creating JS objects in PHP with commas in between
  • Single django queryset to get n adjacent items
  • Is there any purpose for h2-h6 headings in HTML5?
  • Prolog Ambiguous Output
  • Are there any side effects from calling SQLAlchemy flush() within code?
  • Django return user model id with L
  • Django model for a Postgres view
  • Javascript, Regex - I need to grab each section of a string contained in brackets
  • Combining two different ActiveRecord collections into one
  • Checking if an array in C is symmetric
  • Android application: how to use the camera and grab the image bytes?
  • How to revert to previous XCode version?
  • How to get Eclipse Oxygen to run on Java 9
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • NetLogo BehaviorSpace - Measure runs using reporters
  • Spring security and special characters
  • Get object from AWS S3 as a stream
  • JSON with duplicate key names losing information when parsed
  • Font Awesome Showing Box instead of Icons
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • Traverse Array and Display in markup
  • KeystoneJS: Relationships in Admin UI not updating
  • C# - Getting references of reference
  • Angular 2 constructor injection vs direct access
  • Java static initializers and reflection
  • Android Google Maps API OnLocationChanged only called once
  • Is it possible to post an object from jquery to bottle.py?
  • UserPrincipal.Current returns apppool on IIS
  • Python/Django TangoWithDjango Models and Databases