I have a python script "cost_and_lead_time.py" in C:\Desktop\A. This script imports 3 other scripts and a "cost_model.json" file, all of which are in folder A.
Now, I have a simulation result in say C:\Desktop\Model\Results. I have a one line batch file in this folder of "call C:\Desktop\A\cost_and_lead_time.py", but it returns an error when it tries to open the cost_model.json file. It doesn't appear to have an issue importing the 3 other scripts as those appear before the json is opened.
My question is, is there any way to keep this cost_model.json file in that directory and run the script through the batch file without copy/pasting the json file into the results folder? The only way I can think of is to hard code the full path of the file in the python script, but that isn't ideal for me. I'm looking for code to add to the batch file, not python script.
Thanks
Ultimately there needs to be some way to tell your script what you are needing to process.  There's a variety of ways for that, but it really just needs to happen.  I think the most obvious thing to do in the batch file is to copy the target file in place before running your Python script.
However, a cleaner solution might be to take a command line argument into the python script (via sys.argv) which tells the script which file it needs to process.
bat file running py script in different directory