Reputation: 27
Code:
import openpyxl as opxl
wb = opxl.load_workbook('Food.xlsx')
Here is Food.xlsx in flder, but nothing happened.
Error:
FileNotFoundError: [Errno 2] No such file or directory: 'Food.xlsx'
Also, when I use full path method, it returns yet another error. Code:
import openlyxl as opxl
wb = opxl.load_workbook(C:/Users/adminname/Desktop/Workplace/Folder/MiniFolder/FileName)
And I got a bad zip file error.
Upvotes: 0
Views: 1817
Reputation: 2190
Two options;
1. Input the full path to your file;
import openpyxl as opxl
wb = opxl.load_workbook('full_path/to_your/folder/Food.xlsx')
2. Change your script's working directory;
import os
import openpyxl as opxl
# change working directory
os.chdir('full_path/to_your/folder/')
# check the current working directory
print(os.getcwd())
# load your file by name
wb = opxl.load_workbook('Food.xlsx')
Upvotes: 1