After looking at several similar questions on making relative file paths, I have some confusion on how to apply a relative file path for the outputs in my script. I have an application folder called "Master Map Change Report App" in which my script and outputs currently sit.
Right now this app sits on my local C: drive, but I need to move it to a shared drive so that other people can use it. I have all of the outputs going to 'reports' folder (see below). Currently the path to that folder looks like this:
report = "C:/Workspace/Sandbox/MapChangeProject/Master Map Change Report App/reports/map_change_report_{}.xls".format(today).
What I want is something like this:
report = ".../Master Map Change Report App/reports/map_change_report_{}.xls".format(today).
Of course, that doesn't quite work. What do I need to do here so that my outputs will always be within the 'Master Map Change ReportApp/reports' folder no matter where that folder is moved?
Your script is at "Master Map Change Report App". So your relative path for outputs should be "reports/map_change_report_{}.xls".format(today). You may need:
import os
dirname = os.path.dirname(os.path.realpath('__file__'))
filename = os.path.join(dirname, 'reports','map_change_report_{}.xls'.format(today))