Setting directory to search for data with relative path not working

I am sharing code with someone else, and their code loads data using relative paths from a data directory that is external to the project directory.  For example:

project directory: /Users/myname/Documents/GitHub/projectDirectory

data directory: /Users/myname/data

Let's say I am trying to access a file 'file.csv' with absolute path /Users/myname/data/file.csv

In the shared code, this file is just referred to as 'file.csv' (and in fact there are hundreds of data files in the data folder that are accessed with a relative path like this).  How can I set up my environment to find these files with the code as written?

I have tried going into 'Project structure' and adding 'Users/myname/data' as a source directory.  It then shows up in my project but the relative path still does not work.

I have also tried adding it to the interpreter paths, but that does not fix the problem either.  I use a conda environment, does that affect anything about this?

I have tried all the same in PyCharm, and no luck there either.

My computer has an Apple M1 chip and runs Mac OS 12.5.

Any guidance would be greatly appreciated!  Thank you.

 

0

Please sign in to leave a comment.