Whenever I run a python script to read any file, it always throws an error: “FileNotFoundError: [Errno 2] No such file or directory:<file_name>“.
I figured out the problem , but unable to fix it. The python script and the data files are contained in a sub-directory of the parent folder, opened in VS code. The VS code always searches for files/creates one in the parent directory, irrespective of the location of the python script.
The directory structure and code is shown below:
The above code gives an error(line 6), because it is looking for the file “nato_phonetic_alphabet.csv” in the parent directory Testing, rather than the sub-directory First_Test.
The above issue does not exist in PyCharm IDE.
How do I fix this issue ? ( Without changing any paths in the python script)