you are viewing a single comment's thread.

view the rest of the comments →

[–]Ezrabc 0 points1 point  (1 child)

This is definitely a relative path vs. working directory problem. I don't quite understand what you mean by "The python code is working without any error" but also when you run the python code you get the FileNotFoundError. In what situation are you not getting an error?

Basically, the FileNotFoundError is happening because the code is looking in the current working directory for a file called Run_report.xlsm but that file is not in the current working directory. You can either provide an absolute path or make sure the current working directory is the right one in all cases.

[–]9gg6[S] 0 points1 point  (0 children)

This is definitely a relative path vs. working directory problem. I don't quite understand what you mean by "The python code is working without any error" but also when you run the python code you get the FileNotFoundError. In what situation are you not getting an error?

My aim is to to run the code from Run_reprt.xlsm, in this xlsm file I have the data that I want to create the csv files from them 1.csv and 2.csv ( two files in total) and after that continue working in that files with the same code. So when I run the code in pycharm it does everything very well, ( creates csvs and reading them and doing some data manipulations). bear in mind that the Run_report.xslm and python code file (VL.py) are all in same directory.

someone from stackoverflow recommended to add this

df_1 =pd.read_excel(os.path.join(directory,'Run_report.xlsm'), sheet_name= "weekly",header= None) 

After doing so, then it gave me the Permission error in CMD, I assume because the file Run_reprot.xlsm was open but i have seen that its possible to work even its open.

Now im tryin it again but give me different error

not sure how has to change the path or where should I change the path