New to API/python dvlpment- need help with directory path name
Hello,
I'm looking to develop a use-case using the smartsheet-python sdk. Can anyone give me an example for this line and how it should appear in the code block to successfully pull a sheet as csv from smartsheet to a local/shared folder-
download_directory_path
This is from the Get Sheet as Excel / PDF / CSV section on the api doc- https://smartsheet-platform.github.io/api-docs/
Thanks in advance.
Best Answers
-
download_directory_path
refers to the location where you want the sheet to be downloaded.For example, on mac it could be
/Users/genevievep/Downloads
Or linux
/home/genevievep/Downloads
Or Windows
C:\Users\genevievep\Downloads
You can specify any folder you want, and not just the default downloads folder.
Hope this helps!
Cheers,
Genevieve
Join us at Smartsheet ENGAGE 2024 🎉
October 8 - 10, Seattle, WA | Register now -
Honestly, I’m not sure if its possible to specify a file name from the Smartsheet API. But if you're using the Smartsheet python SDK, you should be able to use the built in
os.rename
function to rename it:os.rename('default-sheet-name.csv', 'betterName.csv')
Here's some more information on this: https://docs.python.org/3/library/os.html#os.rename
Join us at Smartsheet ENGAGE 2024 🎉
October 8 - 10, Seattle, WA | Register now
Answers
-
download_directory_path
refers to the location where you want the sheet to be downloaded.For example, on mac it could be
/Users/genevievep/Downloads
Or linux
/home/genevievep/Downloads
Or Windows
C:\Users\genevievep\Downloads
You can specify any folder you want, and not just the default downloads folder.
Hope this helps!
Cheers,
Genevieve
Join us at Smartsheet ENGAGE 2024 🎉
October 8 - 10, Seattle, WA | Register now -
@Genevieve P Thanks, I found a syntax error in my code. Now it worked ! is it possible to rename file other than the default name from smartsheet?
-
Honestly, I’m not sure if its possible to specify a file name from the Smartsheet API. But if you're using the Smartsheet python SDK, you should be able to use the built in
os.rename
function to rename it:os.rename('default-sheet-name.csv', 'betterName.csv')
Here's some more information on this: https://docs.python.org/3/library/os.html#os.rename
Join us at Smartsheet ENGAGE 2024 🎉
October 8 - 10, Seattle, WA | Register now -
Python has an OS module that provides the functions to deal with file management. We can list files in directory and subdirectory programmatically in Python using the OS module.
We need to call the os.listdir() function recursively for subdirectories to create a complete list of files in a given directory tree.
The python os module provides the os.walk() function to iterate over a directory tree.
To list directories, subdirectories, and files in Python, it has excellent inbuilt support that does the job for you. File management and handling is a day to day operations for any programmers.
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 62.3K Get Help
- 364 Global Discussions
- 199 Industry Talk
- 428 Announcements
- 4.4K Ideas & Feature Requests
- 136 Brandfolder
- 127 Just for fun
- 128 Community Job Board
- 445 Show & Tell
- 28 Member Spotlight
- 1 SmartStories
- 283 Events
- 35 Webinars
- 7.3K Forum Archives