I have a file structure like this:
data
mydata.xls
scripts
myscript.py
From within myscript.py, how can I get the filepath of mydata.
From you comments, it seems that book = xlrd.open_workbook(filename)
doesn't like relative path. You can create a path relative to the current file __file__
and then take the absolute path that will remove the relative portions (..
)
import os
filename = os.path.join(os.path.dirname(__file__), '../data/mydata.xls')
book = xlrd.open_workbook(os.path.abspath(filename))