I am reading a python subscript into a python script. The subscript uses an excel file in it's working directory. The structure looks like this
main_folder ->
main.py
subfolder ->
data.xlsx
submain.py
My main script calls the subscript as such:
from subfolder.submain import df
My submain.py
script looks as such:
df = pd.read_excel('data.xlsx')
However on my main.py
script I get the following error:
FileNotFoundError: [Errno 2] No such file or directory: 'data.xlsx'
This is strange because not only does submain.py
run fine by itself, a quick os.listdir()
shows the file to be there:
for f in os.listdir('subfolder'):
print(f)
data.xlsx
submain.py
Does anyone understand this behaviour? Many thanks