1 year ago
#386315
maryam sh
problem with addressing the working folder from within another software python shell
I have a python file that must be called from within a software (which use python 2.7). This python file use np.loadtxt()
to read some data. The software have its own working directory, so when I want to run the python file from within the software, I must put the data files into its working directory. I want to put data files and the python file in a folder and address this folder so that when I run the code by the software, this code find the folder address and its containing data (not to copy paste data in the software's directory each time). I used os.getcwd
as:
data = np.loadtxt(os.getcwd() + "/" + "data.csv")
but it didn't help. While when I get its full address like:
data = np.loadtxt("C:\...\data.csv")
It will work. How could I do this using os
modules to find folder directory automatically. It seems it is running from shell, perhaps it be relating to this.
python
numpy
path
python-2.x
0 Answers
Your Answer