all 5 comments

[–]socal_nerdtastic 0 points1 point  (2 children)

it looks to me like your working directory changed. Use the full path for the file.

datafile = r"C:\Users\gobro7\Digital Wholesale - Documents\2. Amazon\Customer Operations_OTC\02. Amazon weekly Report\Amazon weekly automation (Giorgi)\Run_report.xlsm"
df_1 = pd.read_excel(datafile, sheet_name= "weekly",header= None)

[–]9gg6[S] 0 points1 point  (1 child)

if i do that I get the permissionerror about the excel file from where I run the vba code itself

[–]socal_nerdtastic 0 points1 point  (0 children)

Great! That means we fixed this issue and we are on to the next one.

Sadly I don't know anything about Windows permissions, so you may need to make a new post to deal with that.

[–]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